Groups | Blog | Home
all groups > flash actionscript > april 2006 >

flash actionscript : Help me with some ActionScript please.



WeirdGuy
4/8/2006 11:28:18 PM
First I'll show you the file, say what I want help on and then I'll show the
actionscript.

http://img343.imageshack.us/my.php?image=germ1go.swf

(Copy pas the link the forums are glitchy...)

That's the VERY basic flash.

I'm basically making the template for a very basic game (that'll probably suck
lol). But I need to be able to set a max speed for the movement of the little
ball. Basically I want to make it easier to control, make it have a max speed,
make it slow down over a bit of time if you're not pressing the key, and stuff.
Also the borders... it's pretty easy to get the ball past the borders if you
just hold one direction. Sometimes it goes right through.

Please help me. If you can please say it in simple terms and simple
actionscript so that I can understand. I'm new at this.

Here's the ActionScript I'm using right now:

****
xdir = 0;
ydir = 0;
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
thekey = Key.getCode();
trace(thekey);
if (thekey ==65) {
xdir -= 2;
}
if (thekey ==68) {
xdir += 2;
}
if (thekey ==87) {
ydir -= 2;
}
//if (Key.isDown(Key.DOWN)) {
if (thekey ==83) {
ydir += 2;
}
};
Key.addListener(keyListener);
this.onEnterFrame = function() {
if (cell_mc._y<=0) {
ydir = ydir*-1;
}
if (cell_mc._x<=0) {
xdir *= -1;
}
if (cell_mc._x>=517) {
xdir *= -1;
}
if (cell_mc._y>=367) {
ydir *= -1;
}
if (cell_mc.hitTest(blockade_mc)) {
xdir *= -1;
ydir *= -1;
}
cell_mc._x += xdir;
cell_mc._y += ydir;
};
****

It makes one piece of teh code into a smiley lol.
WeirdGuy
4/9/2006 6:30:05 PM
:(

AddThis Social Bookmark Button