Jump to content

help in phaser


alkhalidee
 Share

Recommended Posts

First have a variable controlling which direction the enemy is moving ( 0 = stationary, 1 = left, 2 = right )

Then have a timer that changes that variable every 5 seconds.

 

So in create you have:

aiMoveCheck = game.time.now;

In update you have:

if (game.time.now - aiMoveCheck > 5000)  // Every 5 seconds.{  // If enemy moving left then make right, if right then make left.  if (enemyMove == 1)     enemyMove == 2  else if (enemyMove == 2)     enemyMove == 1   aiMoveCheck = game.time.now;} if (enemyMove == 1) // Left  // Move enemy leftelse if (enemyMove == 2) // Right  // Move enemy right
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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