1) Create an actor and let's name it spikes.
2) Add the image called spike1.png into the actor.
3) Change the horizontal wrap to Tile.
4) Click and drag the spikes actor onto the stage. Resize the spikes actor on stage to make it longer. You will notice that the spikes image will be repeated/tiled.
EnemiesCreate another actor called EnemyA.
Add the image enemyA1.png into it.
Add 3 actor attributes:
startX value: 0 (real)
endX value: 0 (real)
speed value: 50 (integer)
Add the animate behavior with these 4 images
Add these behaviours into it:
Relative to: scene
self.Motion.LinearVelocity.X to self.speed
Bounce when colliding with actor : platform
Add these rules into it:
When Any conditions are valid:
If self.Position.X > self.endX
if self.Position.X < self.startX
self.Motion.LinearVelocity.X to - self.Motion.LinearVelocity.X
If self.Motion.LinearVelocity.X > 0
self.Graphics.Flip Horizontally to true
self.Graphics.Flip Horizontally to false
Now drag the EnemyA actor onto the stage.
Change the value of the actor’s instance attributes:
startX and endX to your desired position on the stage.
Make sure the value of startX is lesser than endX. This will make the enemy move from left to right continuously.
Preview your game!
We will continue on to the next tutorial where we will make the hero react to the obstacles and enemies.