Click to See Complete Forum and Search --> : Action Script Question
-Mystikal
09-02-2005, 01:41 PM
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
Ultra Pulse
09-02-2005, 01:53 PM
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;
}
}
-Mystikal
09-02-2005, 01:59 PM
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
Ultra Pulse
09-02-2005, 02:00 PM
If you're going to be using the flash 7 plugin, I didn't capitalize certain things, and it might not work.
-Mystikal
09-02-2005, 02:06 PM
Ah i see that might pose a problem
for people without it
Ultra Pulse
09-02-2005, 02:10 PM
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.
-Mystikal
09-02-2005, 02:16 PM
Sweet :thumbsup:
Ultra Pulse
09-02-2005, 02:27 PM
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...
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;
}
}
-Mystikal
09-02-2005, 02:38 PM
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
Ultra Pulse
09-02-2005, 02:41 PM
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.
-Mystikal
09-02-2005, 02:51 PM
No need i already did it. LOL
Thanks for all the help.
-Mystikal
-Mystikal
09-02-2005, 02:55 PM
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
Ultra Pulse
09-02-2005, 04:09 PM
I think you goto the fill tool, and the fourth option is the transperancy option. set it from 0-100.
flashkit.com
Copyright WebMediaBrands Inc., All Rights Reserved.