|
-
Action Script Question
I created a maze game where you have to guide your ball to the exit.
I have all the action script for the walls and such, but not for the controls.
Im looking for an action script where if your left,right,up, or down key is
pushed, you move left right up or down according to what button you pushed.
Thanks,
-------Mystikal
-
Some dude, says hi
UPDATE: you might have to press on the screen for the code to work.
All tested and ready to go, if you want it faster or slower change the speed value higher or lower. Also pay attention to the comment line after "//"
onclipEvent(load){
speed = 5 //change this number to make the object move faster
}
onClipEvent(keydown){
if (key.isDown(key.DOWN)){
_y += speed
}
}
onClipEvent(keydown){
if (key.isDown(key.UP)){
_y -= speed;
}
}
onClipEvent(keydown){
if (key.isDown(key.RIGHT)){
_x += speed;
}
}
onClipEvent(keydown){
if (key.isDown(key.LEFT)){
_x -= speed;
}
}
Last edited by Ultra Pulse; 09-02-2005 at 12:55 PM.
Reason: UPDATE on making it work
-
Thanks
Why thank you ultra pulse.
Works fine.
-Mystikal
Edit: I showed my friend the game
and he suggested something.
When you push the left key, it
shows the left side of the object.
So say you had a sprite and you
hit the left arrow key, it would
show him looking to the left.
Any one know what i can do?
If you can help thanks
-Mystikal
Last edited by -Mystikal; 09-02-2005 at 01:06 PM.
Reason: Another question -.-
-
Some dude, says hi
If you're going to be using the flash 7 plugin, I didn't capitalize certain things, and it might not work.
-
I see
Ah i see that might pose a problem
for people without it
Last edited by -Mystikal; 09-02-2005 at 01:07 PM.
Reason: BLAH
-
Some dude, says hi
 Originally Posted by -Mystikal
Why thank you ultra pulse.
Works fine.
-Mystikal
Edit: I showed my friend the game
and he suggested something.
When you push the left key, it
shows the left side of the object.
So say you had a sprite and you
hit the left arrow key, it would
show him looking to the left.
Any one know what i can do?
If you can help thanks
-Mystikal
Yes, I can fix it, But it'll take a few minutes so hold on a sec.
-
:d
Sweet
-
Some dude, says hi
Sorry, I was getting the correct degrees to turn, I finally found an image on google, hope this is what you want, also if you don't need something tell me.
oh crud, the guy turns facing the way, I'll just edit it when it's ready again.
this only works for an overhead view...
Code:
onclipEvent(load){
speed = 5 //change this number to make the object move faster
}
onClipEvent(keydown){
if (key.isDown(key.DOWN)){
this.rotation = 0;
this._rotation = 180;
_y += speed;
}
}
onClipEvent(keydown){
if (key.isDown(key.UP)){
this.rotation = 0;
this._rotation = 0;
_y -= speed;
}
}
onClipEvent(keydown){
if (key.isDown(key.RIGHT)){
this.rotation = 0;
this._rotation = 90;
_x += speed;
}
}
onClipEvent(keydown){
if (key.isDown(key.LEFT)){
this.rotation = 0;
this._rotation = 270;
_x -= speed;
}
}
Last edited by Ultra Pulse; 09-02-2005 at 01:35 PM.
Reason: Forgot code
-
Sweet
Ya it works, i see what you meen by overhead.
Mabye it would work if when you pressed the button,
it changed the pic so that its facing the other way.
But, this will do fine for now.
-Mystikal
-
Some dude, says hi
Correct, all you have to do is make 4 frames on the MC. put stop commands on all of them, instead of the "this._rotation = somenumber" you put "gotoAndStop ("framename"), if you give me your FUN file, I'll gladly do it, except you have to draw his back.
-
yay
No need i already did it. LOL
Thanks for all the help.
-Mystikal
-
One more...
Just one more question,
the pic im importing is a .png
but i want to know how to make
it transparent.
thanks for ALL the help
-Mystikal
-
Some dude, says hi
I think you goto the fill tool, and the fourth option is the transperancy option. set it from 0-100.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|