zelcard Posted July 20, 2015 Share Posted July 20, 2015 Greetings, I recently started working in Phaser and it seems like a pretty good framework, for practice I started working on simple top down shooter game and now it seems I have a problem with move toward the object functionality (enemies moving toward player), I have tried few solutions including all from this post: http://www.html5gamedevs.com/topic/3441-movetoobject-help/ but I was unable to make it work, I'm complete noob and probably doing something wrong but I cant figure out what, so I hope some you guys can help me out, thanks in advance. Here is the part of code I have done so far: function create() { game.world.width = 800; game.world.width = 600; game.physics.startSystem(Phaser.Physics.ARCADE); bullets = game.add.group(); bullets.enableBody = true; bullets.physicsBodyType = Phaser.Physics.ARCADE; bullets.createMultiple(50, 'bullet'); bullets.setAll('checkWorldBounds', true); bullets.setAll('outOfBoundsKill', true); player = game.add.sprite(400, 300, 'arrow'); player.anchor.set(0.5, 0.5); game.physics.enable(player, Phaser.Physics.ARCADE); player.body.allowRotation = false; enemies = game.add.group(); enemies.enableBody = true; createEnemies();} function createEnemies () { for (var y = 0; y < 2; y++) { for (var x = 0; x < 5; x++) { var enemy = enemies.create(game.world.randomX, game.world.randomY, 'enemy'); enemy.anchor.setTo(0.5, 0.5); enemy.body.moves = false; } }} function update() { player.rotation = game.physics.arcade.angleToPointer(player); if (game.input.activePointer.isDown) { fire(); } game.physics.arcade.overlap(bullets, enemies, collisionHandler, null, this);} Link to comment Share on other sites More sharing options...
rich Posted July 21, 2015 Share Posted July 21, 2015 You ought to explain exactly how it doesn't work - as no-one can actually run your code above, and there doesn't appear to be any code in there that would actually move anything anywhere Link to comment Share on other sites More sharing options...
zelcard Posted July 21, 2015 Author Share Posted July 21, 2015 EDIT: Solved, it was a noob mistake, I set enemy.body.moves = false; and expected them to move , thanks for the help anyways guys! Link to comment Share on other sites More sharing options...
Recommended Posts