npilla Posted November 13, 2013 Share Posted November 13, 2013 I'm trying to get a group of sprites to converge on a player that is at the center of the world. Is it possible to get the group to converge(tween) on the game.world.centerX, game. world.centerY? Link to comment Share on other sites More sharing options...
Alvin Posted November 14, 2013 Share Posted November 14, 2013 Yeah it is, the properties you mentioned are just values, so you can totally do :tween.to({ y: game.world.centerY }, 1000, Phaser.Easing.Bounce.In);Of course this is just an example. Link to comment Share on other sites More sharing options...
npilla Posted November 14, 2013 Author Share Posted November 14, 2013 I can't get the whole group to converge on the center. I'm going to try and get each individual enemy to converge. Link to comment Share on other sites More sharing options...
Alvin Posted November 14, 2013 Share Posted November 14, 2013 You can use group.forEach plus game.physics.moveToXY, you can check out the examples for code samples. Link to comment Share on other sites More sharing options...
npilla Posted November 15, 2013 Author Share Posted November 15, 2013 Thank you very much for your help. I'll go that route. Link to comment Share on other sites More sharing options...
Alvin Posted November 15, 2013 Share Posted November 15, 2013 You're welcome. If that solves your problem, can you mark this topic as "answered" ?Thanks Link to comment Share on other sites More sharing options...
npilla Posted November 15, 2013 Author Share Posted November 15, 2013 I've gotten closer to my answer but I'm running into another problem. Here's my code: aliens.forEach(game.physics.moveToXY, game.physics, 300, -400, false, 50); I want my aliens to converge on the player that is 400, 300 but I can't get the aliens to move to that coordinate. I've tinkered with the coordinates but can't get them to move to the center. Link to comment Share on other sites More sharing options...
npilla Posted November 15, 2013 Author Share Posted November 15, 2013 game.physics.moveToObject(aliens, player, 50, null); Tried this but getting a velocity error. Link to comment Share on other sites More sharing options...
Alvin Posted November 15, 2013 Share Posted November 15, 2013 You don't need to pass 'null' as a final argument, where did you find that ? Link to comment Share on other sites More sharing options...
npilla Posted November 15, 2013 Author Share Posted November 15, 2013 I put that in myself but still getting Uncaught TypeError: Cannot read property 'velocity' of undefined Link to comment Share on other sites More sharing options...
hackenstein Posted November 16, 2013 Share Posted November 16, 2013 Probably because aliens are a group and thus have no body. Try using moveToObject on the individual alien sprites in the group with forEach. Link to comment Share on other sites More sharing options...
Recommended Posts