khleug35 28 Report post Posted September 10, 2017 Hello everyone, I am developing a platform game like super Mario , I hope the enemy can move left and right horizontal and loop this. I just use very stupid way to make it. I use this code is work. if (enemy.x<= 450){ enemy.body.velocity.x = +200; } else if (enemy.x>= 800){ enemy.body.velocity.x = -200; } if I have more than one enemy, I need to set each of their values. I try to use game.add.tween eg game.add.tween(enemy).to({ x: enemy.x+80 }........, It also work!!!!!!! but same problem , I need to set each of their values. I try to use time.events, but no success. What are the easy way to set enemy auto move left and right horizontal and loop this? Thanks you very much. Quote Share this post Link to post Share on other sites
samid737 117 Report post Posted September 10, 2017 You could use the yoyo'ing for tweens (the last argument set to true): Quote Share this post Link to post Share on other sites
samme 711 Report post Posted September 10, 2017 1 Taz reacted to this Quote Share this post Link to post Share on other sites
Taz 43 Report post Posted September 10, 2017 Alternatively you can also use forEach to repeat your update process for each enemy, like this for instance: Quote Share this post Link to post Share on other sites
khleug35 28 Report post Posted September 11, 2017 12 hours ago, samid737 said: You could use the yoyo'ing for tweens (the last argument set to true): Thank you very much!!!!!!!!nice Quote Share this post Link to post Share on other sites
khleug35 28 Report post Posted September 11, 2017 12 hours ago, samme said: Thank you very much!!!!!!!!nice Quote Share this post Link to post Share on other sites