khleug35 Posted September 10, 2017 Share 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. Link to comment Share on other sites More sharing options...
samid737 Posted September 10, 2017 Share Posted September 10, 2017 You could use the yoyo'ing for tweens (the last argument set to true): Link to comment Share on other sites More sharing options...
samme Posted September 10, 2017 Share Posted September 10, 2017 Taz 1 Link to comment Share on other sites More sharing options...
Taz Posted September 10, 2017 Share Posted September 10, 2017 Alternatively you can also use forEach to repeat your update process for each enemy, like this for instance: Link to comment Share on other sites More sharing options...
khleug35 Posted September 11, 2017 Author Share 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 Link to comment Share on other sites More sharing options...
khleug35 Posted September 11, 2017 Author Share Posted September 11, 2017 12 hours ago, samme said: Thank you very much!!!!!!!!nice Link to comment Share on other sites More sharing options...
Recommended Posts