Search the Community
Showing results for tags '2.0'.
-
Hello all, I have two simple questions. First of all, is it possible to collide a Phaser.Sprite with a Phaser.Rectangle? If not, is it possible to collide two Phaser.Rectangles? Thanks in advance...
-
I'm currently starting with phaser, so this might not be the best way to move a sprite. But it was working for me on 2.0 and now it doesn't so I'm not sure if I am doing things the wrong way or if it's a bug. Given the following code: http://pastebin.com/2N4iAmTd I get 2 different behaviours depending on using 2.0 or 2.0.1 this.bird.body.xworks for 2.0 and moves the sprite apropiately. This doesn't seem to work on 2.0.1 as the value changes but it is not updated on redraw this.bird.x does not work for 2.0 (I'm not even sure it's valid) but in 2.0.1. is valid, but instead of moving the sprite to the new X position it just adds some x-velocity to it and keeps moving it. So, what am I doing wrong? did I just found a bug? Thanks for any tips/solution
-
I was experimenting with spawning enemies from the right side of the game's canvas. The player, being on the left side shoots the enemies coming from the right. I have a problem though. When the player shoots the enemy while it spawns a couple pixels away from the right side of the screen, the enemy dies (I made a collision handler), but the problem comes when the enemy reaches halfway past the spawn point. It seems that if the enemy gets too close to the player the bullets don't seem to effect the enemy at all. The enemy seems to only die a couple of pixels away from the right side of the screen. Here is how I have things set up: Currently using Phaser 2.0 //Create function with bullets bullets = this.game.add.group(); bullets.enableBody = true; bullets.physicsBodyType = Phaser.Physics.ARCADE; bullets.createMultiple(50, 'bullet'); bullets.setAll('anchor.x', 0.5); bullets.setAll('anchor.y', 0.5); bullets.setAll('outOfBoundsKill', true);//UPDATE functionthis.game.physics.arcade.overlap(bullets, clone, this.enemyKill, null, this);//Method used to spawn enemies//I call a function named 'lvl1' that spawns enemies from the right side of the screen levelOne: function() { this.lvl1 = this.game.time.create(false); this.lvl1.start(); this.lvl1.onComplete.add(this.watchCounter, this); this.lvl1.repeat(Phaser.Timer.SECOND * 2, 10, this.enemyOne, this); },//This function uses the Phaser timer method to call a function to create enemies 10 times every 2 seconds//The function for the enemy is down below:enemyOne: function() { clone = this.game.add.sprite(this.game.world.height + 100, (100 + spawnLimit), 'CloneOne'); //I "bottlenecked" the spawn area to be between a specific areathis.game.physics.enable(clone, Phaser.Physics.ARCADE); clone.enableBody = true; clone.anchor.setTo(0.5, 0.5); clone.body.velocity.x = -110; clone.animations.add('run', [11, 10, 9, 8, 7, 6], 10, true); clone.animations.play('run'); },//Here is the collision handler enemyKill: function(bullet, clone) { bullet.kill(); clone.kill(); }//Here is the players fire methodfire: function() { if (this.game.time.now > nextFire && bullets.countDead() > 0) { var shoot = this.game.add.audio('shoot'); shoot.play(); nextFire = this.game.time.now + fireRate; bullet = bullets.getFirstDead(false); bullet.body.velocity.x = 350; bullet.reset((player.x + 65), (player.y + 20)); bullet.rotation = this.game.physics.arcade.moveToPointer(bullet, 300); } }, EDIT: I just did some debugging using the line of code below and discovered that when the enemy reaches halfway across the screen the collision box literally disappears. How can that be? EDIT: The only "enemy" that takes collision is the last enemy that is spawned. render: function() { this.game.debug.body(player); this.game.debug.body(clone); } Thank you all in advance.
- 1 reply
-
- phasercollisiongame
- problem
-
(and 3 more)
Tagged with: