Jump to content

JackBid

Members
  • Content Count

    19
  • Joined

  • Last visited

About JackBid

  • Rank
    Member
  • Birthday 04/29/1999

Contact Methods

  • Website URL
    www.jackbiddlecombe.co.uk

Profile Information

  • Gender
    Male
  • Location
    UK
  1. There is no set way to restart your game, its up to you to control how your game restarts and under what circumstances. However I think it can generally be broken down into two parts: 1. Detect that your game needs restarting. Maybe you want to restart the game when the user runs out of lives, or perhaps if he has shot a certain amount of enemies or if he clicks a restart button in your game. I would suggest putting some checks in your update function to see if the game need to be restarted, if they evaluate to true I would call a restart function. 2. Now you know that the gameplay needs r
  2. when I am creating a new group of sprites, if it possible to add an animation to these sprites? I could not find an example of it, or a previous post in the forums. I tried doing this: explosions.create(x, y, 'explosion');explosions.forEach(function(item){ item.animations.add("explode", [0,1]); item.animations.play("explode", 7, true);});However it responds with the error: Uncaught TypeError: Cannot read property 'uuid' of null
  3. Yeah pretty much, I checked what angled surface ii was (eg. if the bullet is moving up and should be reflecting to the right) and then I would center the bullet in the bounding box of that object, remove all velocity, rotate it to point in the right direction and add a new velocity. This does mean that the way the bullet reflects is not correct in terms of physics, but it is passable as the bullet moves fast and the user can barely notice the change. It is very simple and works surprisingly well, especially as I spend a while trying to think of more complex ways to achieve this!
  4. Here is my entry using phaser: http://www.ludumdare.com/compo/ludum-dare-28/?action=preview&uid=21527 It is a bit buggy currently, I might try and develop the idea more though.
  5. You might want to check out this example, it shows a sprite colliding with a tilemap without any gravity. Make sure your using tileset.setCollision and tileset.setcollision range as in the example, you may also want to post some of your code in case it is a different bug in your code causing it!
  6. What I am trying to achieve is when a bullet is fired at a 45 degree slope, it bounces off at a 90 degree angle, this may be clearer looking at the attached image. As you can see you would expect the bullet to bounce off at a 90 degree angle when it collides with the slope. I have all the logic and code ready to bounce the bullet off at this angle, my problem is that the bounding box around the slope is square or rectangular, as a result the bullet bounces off the slope before it actually collides with the pixels. I read in the forums earlier that phaser only supports square/rectangular coll
  7. I think the only way to do this is to use game.debug: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create, render: render });var floor;function create() { floor = new Phaser.Rectangle(0, 550, 800, 50);}function render () { game.debug.renderRectangle(floor,'#0fffff');}Is there a particular reason why you do not want to use game.debug?
  8. In one of the project I am working on. an animation is played when a sprite is colliding and the animation stops when the sprite exits collision. All I want to do is to check when the animation has reached the end (before is loops round again), or a simple method to check which frame an animation is on so I can check if it is on the last frame. So in other words, how you check which frame a sprite is on during an animation, or is there a way to check when a sprite has finished the animation before looping. Thanks.
  9. Just a guess, but you may need to use the setAll group method. group.setAll(scale.x, 2);i have not tested this myself, but it may be worth a try!
  10. Yes, but my main problem is that mummies and swords are arrays which contain objects. Part of the object is a phaser sprite, but the object as a whole is not just a sprite, this is where I am not sure how to fix it.
  11. Sword = function (x, y) { this.sprite = game.add.sprite(x, y, 'sword'); this.sprite.anchor.setTo(0.5, 0.5); this.sprite.immovable = true; this.sprite.body.velocity.y = -150; this.sprite.outOfBoundskill = true;};Mummy = function (x, y) { this.sprite = game.add.sprite(x, y, 'mummy'); this.sprite.anchor.setTo(0.5, 0.5); this.sprite.immovable = true; this.sprite.body.velocity.y = 30; this.sprite.animations.add('walk'); this.sprite.animations.play('walk', 7, true);}var swords = [];var mummies = [];function preload(){ game.load.spritesheet('player', 'assets/player.png', 64, 22); game.load.spriteshee
  12. My problem is that I do not know how to check if a body exits a collision state. I know how to check if it enters a collision, but not if it exits.
  13. I need to find a way to detect when a sprite exits collisions. My goal here is that when a sprite enters a collision an animation is played and when the sprite exits the collision the animation is paused leaving the sprite at a different frame from a sprite sheet. If there a simple built in function to phaser to achieve this? Or do I need to find a different solution. Here is my simple code so far: function update() { game.physics.collide(cup, sprite2, collisionHandler, null, this);}function collisionHandler (obj1, obj2) { cup.animations.play('fill', 10);}
  14. I spent a long time looking at lots of examples and managed to solve my problem! (On a side note I think I am beginning to realize how powerful phaser can be). Here is what i did if anyone needs it: Enemy = function(){ this.x = game.world.randomX; this.y = game.world.randomY; this.minSpeed = -75; this.maxSpeed = 75; this.vx = Math.random()*(this.maxSpeed - this.minSpeed+1)-this.minSpeed; this.vy = Math.random()*(this.maxSpeed - this.minSpeed+1)-this.minSpeed; this.enemySprite = game.add.sprite(this.x,this.y,"enemy"); this.enemySprite.
  15. I am very new to phaser but what I am trying to achieve here is lots of sprites (in a group) moving at a constant speeds in different directions. This is the code I have so far: var game = new Phaser.Game(600, 400, Phaser.AUTO, '', { preload: preload, create: create, update: update });var enemies;var numOfEnemies = 10;function preload() { game.load.image('gold', 'assets/gold.png');}function create() { game.stage.backgroundColor = 0x8C8C8C; enemies = game.add.group(); for (var i=0; i<numOfEnemies; i++) { createEnemy(); }}function update() { for (var i=0; i<num
×
×
  • Create New...