Jump to content

[Solved]How to move the enemy left and right horizontal loop?


khleug35
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...