======
INTRO
======
This is really a simple tut for all what it does is create a object that moves from one side of the screen to the other and when it gets tho the other side it appeas in a random spot on the other side. For example in This Game the scrolling koopas move from the left to right EASY
Please Note that all this script is designed to a 550 X 400 flash movie
Please E-Mail Me for any questions or post here.
http://flash-fantasy.com
=========
Let's Do It
=========
1. Create a new Flash Document (550 X 400)
2.Insert a new MC and call it bad
-- In that MC draw a simple circle
3. Now go back to the main scene and open the library (CTRL + L) and drag the bad MC onto the main scene
4.Open the actions panel (F9) and add these actions :
onClipEvent (load) {
this._x += 10;
if (this._x >= 560) {
this._x = 0
}
}
INFO
onClipEvent(load) means when the flash player loads the movie
this._x += 10; Means that the Bad MC increases then X axis by 10 each thime thus making it move across the screen
if (this._x >= 560) Means if the Bad MC is greater than or equal to 560 in the X axis...
this._x = 0 Place the Bad MC 0 in the X axis
5.Now push CTRL + ENTER and see if the Bad MC moves across the screen.
================
CONGRATULATIONS
================
You now have a perfectly good moving enemy for a shooting game.
Additinal Info
Ok there is still a few things to tell ya before i go so read...
1. Up And Down
Ok so you have a enemy going form left to right well maby you want it to go from top to bottom well its easy change the "this._x" to "this._y" and "if (this._x >= 560)" to "if (this._y >= 410)" easy
eg.
onClipEvent (load) {
this._y += 10;
if (this._y >= 410) {
this._y = 0
}
}
And Also if you want it to go from "down to up" or "right to left" just make the "this._y += 10;" to "this._y += -10;"
In other words make the speed to a negative so it moves backwards
But by reversing the way it moves you will have to change the actions as well:
eg.
onClipEvent (load) {
this._y += -10;
if (this._y >= -10) {
this._y = 0
}
}
And Thats All Folks
ENJOY...