Post by yoshipros on Jan 8, 2006 14:10:01 GMT
Welcome Everyone
To your First Action Script Class! Today i will teach you how to do basic Movement!
Okay get your books out and turn to yesterdays page!
If you look at you picture of Flash MX you can see a Action Panel and Properties Panel! now get your pencils out and draw a Character that you want!
Yes thats right! Something like say a Car of a Spaceship!
Then on you magic table keyboards press F8 and convert this Shape or Car or What ever you done into a movie clip!
Then if your action panel isnt open press F9 and it will open! saying "Actions" at the top left corner of the panel! then make sure the shape is highlighted then put this code in
(dont worry ill tell you what the code is telling flash!
onClipEvent (enterFrame) {
if (Key.isDown(37)) {
_x=_x-2;
}
if (Key.isDown(38)) {
_y=_y-2;
}
if (Key.isDown(39)) {
_x=_x+2; This Code Tells flash how fast to go along the X Axis
}
if (Key.isDown(40)) {
_y=_y+2; And this code does the same but along the Y Axis
}
}
Okay Now test It!
Does it work everyone?
Okay right,
If your making a game and you have a Wall anywere and you dont want a Car going though it know would you!
Yes Bob!
"Well Sir!
if you have a car on that action script it says that i can fly up into the sky and if its a car we dont want that!"
Oh Yes sorry Bob!
okay ill tell you that code again so if you have a car it wont go flying in the sky (but if its a flying car leave the code as it is!)
if (Key.isDown(39)) {
_x=_x+2; This Code Tells flash how fast to go along the X Axis
}
if (Key.isDown(40)) {
_y=_y-0; Now i have changed it to -0 so it wont fly!
}
}
There you go Bob
"Sir"
"Sir"
Yes Steve
"Well Sir,
What happens if you want the car to go really fast!?!"
Well Steve!
all you have to do is change this
if (Key.isDown(39)) {
_x=_x+8; <--- The Higher the Number the Faster the Car or Person will go around on the page!
}
if (Key.isDown(40)) {
_y=_y-0;
}
}
"Thanks Sir!"
No Problem Steve!
Okay everyone Where was i....... Oh yer! so if you have a car and you dont want it go though a wall heres a little something!
okay ill go step by step!
1. Make the Wall!
2. Convert it into a MOVIECLIP
3. Make the Instance= wall
4. Open Actions panel
5. Then Put in this code!
if (hitTest(_level0.wall)==true) {
_x=_x-0;
} <----- This Means that it wont go though the Movie Clip called wall! as you can see i put this bit
(hitTest(_level0.wall)==True <--- There it says the Movieclips name (wall) this means it wont go though it!
"So Sir whats the Whole Code?"
Bob ill tell you it again just for you!
onClipEvent (enterFrame) {
if (Key.isDown(37)) {
_x=_x-2;
}
if (Key.isDown(38)) {
_y=_y-2;
}
if (Key.isDown(39)) {
_x=_x+2;
}
if (Key.isDown(40)) {
_y=_y+2;
}
if (hitTest(_level0.wall)==true) {
_x=_x-2;
}
}
Remember bob this code has the Wall Part included in it to!!
So class i hope you learnt something today!
See you next Class!
(Please email me if any of the codes are wrong i think they are all correct!
CYA
To your First Action Script Class! Today i will teach you how to do basic Movement!
Okay get your books out and turn to yesterdays page!
If you look at you picture of Flash MX you can see a Action Panel and Properties Panel! now get your pencils out and draw a Character that you want!
Yes thats right! Something like say a Car of a Spaceship!
Then on you magic table keyboards press F8 and convert this Shape or Car or What ever you done into a movie clip!
Then if your action panel isnt open press F9 and it will open! saying "Actions" at the top left corner of the panel! then make sure the shape is highlighted then put this code in
(dont worry ill tell you what the code is telling flash!
onClipEvent (enterFrame) {
if (Key.isDown(37)) {
_x=_x-2;
}
if (Key.isDown(38)) {
_y=_y-2;
}
if (Key.isDown(39)) {
_x=_x+2; This Code Tells flash how fast to go along the X Axis
}
if (Key.isDown(40)) {
_y=_y+2; And this code does the same but along the Y Axis
}
}
Okay Now test It!
Does it work everyone?
Okay right,
If your making a game and you have a Wall anywere and you dont want a Car going though it know would you!
Yes Bob!
"Well Sir!
if you have a car on that action script it says that i can fly up into the sky and if its a car we dont want that!"
Oh Yes sorry Bob!
okay ill tell you that code again so if you have a car it wont go flying in the sky (but if its a flying car leave the code as it is!)
if (Key.isDown(39)) {
_x=_x+2; This Code Tells flash how fast to go along the X Axis
}
if (Key.isDown(40)) {
_y=_y-0; Now i have changed it to -0 so it wont fly!
}
}
There you go Bob
"Sir"
"Sir"
Yes Steve
"Well Sir,
What happens if you want the car to go really fast!?!"
Well Steve!
all you have to do is change this
if (Key.isDown(39)) {
_x=_x+8; <--- The Higher the Number the Faster the Car or Person will go around on the page!
}
if (Key.isDown(40)) {
_y=_y-0;
}
}
"Thanks Sir!"
No Problem Steve!
Okay everyone Where was i....... Oh yer! so if you have a car and you dont want it go though a wall heres a little something!
okay ill go step by step!
1. Make the Wall!
2. Convert it into a MOVIECLIP
3. Make the Instance= wall
4. Open Actions panel
5. Then Put in this code!
if (hitTest(_level0.wall)==true) {
_x=_x-0;
} <----- This Means that it wont go though the Movie Clip called wall! as you can see i put this bit
(hitTest(_level0.wall)==True <--- There it says the Movieclips name (wall) this means it wont go though it!
"So Sir whats the Whole Code?"
Bob ill tell you it again just for you!
onClipEvent (enterFrame) {
if (Key.isDown(37)) {
_x=_x-2;
}
if (Key.isDown(38)) {
_y=_y-2;
}
if (Key.isDown(39)) {
_x=_x+2;
}
if (Key.isDown(40)) {
_y=_y+2;
}
if (hitTest(_level0.wall)==true) {
_x=_x-2;
}
}
Remember bob this code has the Wall Part included in it to!!
So class i hope you learnt something today!
See you next Class!
(Please email me if any of the codes are wrong i think they are all correct!
CYA