Step 4

Create the enemy


Create a new function called ‘createEnemy‘ that will control our enemy.

Set up a new sprite variable and call it ‘enemySprite‘.

Animate the sprite using 4 frames from the gallery.

Enemy Movement


Next we will set the movement our enemy will have on the screen.

Set up the velocity to two random blocks from 0 to 75.

Set up the bounce on wall to ON.

Enemy spawn


Lastly we will set up were the enemy will spawn on the screen.

Create an if else statement that will use a 50% chance to set position of the enemy in one corner or the opposite corner.