I’ve been thinking about how targeting the closest enemy would work and started experimenting with the algorithm. Basically AS has an array method called sortOn, that sorts objects properties in any order you want. Well, that’s the catch. It only sorts objects, not movieClips.
The work around is simple enough; when creating a new enemy object, just save a reference to the movieClip on stage inside the object’s property.
This is a Flash ActionScript 2.0 heat seeking missile script for games. Includes AS2 dynamic smoke effects & dynamic animated explosion effects. Our missiles also need something to lock on to so I added a simple enemy random movement script.
Flash Game Weapon Preview
Download Fla Sample
Customizable Missile Settings
reloadSpeed – how long it takes the missile launcher to reload
missileSpeed – how fast the missile travels
turnRate – how fast the missile turns toward the target
Customizable Explosion Settings
explosionParticleAmount – amount of explosion particles
explosionDistance – explosion spread distance
explosionSize – size of explosion particles
explosionAlpha – transparency of the explosion particles
Here is a simple AS2 enemy creation/ai script that allows you to create enemies that move about randomly inside a container movieclip. You can set custom movement boundaries/borders. When an enemy hits the border, it will “bounce off” and move in the opposite direction.
33 Comments »