We could set up a spawner to create a load of monsters for us, but we'll use a timeline instead. A timeline can issue commands.
Our timeline will simply issue the same create object command over and over in a loop.
Before we do this, remove the single monster from the Scene. We don't need it any more:
[Scene] ChildList = PlatformObject # MiddlePlatformObject # TopLeftPlatformObject # TopPlatformObject # TopRightPlatformObject # StarObject
Now to create a simple track:
[MonsterMakerTrack] 1 = Object.Create MonsterObject Loop = True
This will create monsters over and over every second for us. But the monster objects need to start at a random position each time. Change the monster object to have a range of starting x positions:
[MonsterObject] Graphic = MonsterGraphic1 AnimationSet = MonsterAnimationSet Position = (20, 0, 0) ~ (600, 0, 0) Scale = 2.0 Body = MonsterBody
Finally, to actually use the track which will create monsters, add it to the TrackList property in the Scene section:
[Scene] ChildList = PlatformObject # MiddlePlatformObject # TopLeftPlatformObject # TopPlatformObject # TopRightPlatformObject # StarObject TrackList = MonsterMakerTrack
Looking great! Monsters should be dropping in all over the place:
Some tweaks can be added to the monster and the body to improve things a little:
[MonsterObject] Graphic = MonsterGraphic1 AnimationSet = MonsterAnimationSet Position = (20, 0, 0) ~ (600, 0, 0) Speed = (-20, 0, 0) ~ (20, 0, 0) Scale = 2.0 Body = MonsterBody [MonsterBody] Dynamic = true PartList = MonsterBodyPart AllowGroundSliding = false AngularDamping = 50 LinearDamping = 0.2; [MonsterBodyPart] Type = box Solid = true SelfFlags = monster CheckMask = hero # platforms # bullet Friction = 10; Restitution = 0.2; Density = 20
Speed on the object will give the monsters a little random left/right movement. The
Friction on the bodypart will make the monster less slippery on the ground.
LinearDamping on the body will slow him down a little over time if he's too fast. The high
AngularDamping will ensure the monster tips over the edge but not rotate and tumble wildly.
Finally, a touch of
Restitution on the body will allow it to bounce just a touch when landing from a height.
That should work a little better.
Next: Part 18 – Exploding Monsters.