Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-05-2003, 05:36 PM   #1
willbill
Registered User
 
Join Date: Jun 2003
Posts: 1
Question movie clip animation

i went through the tutorial on bulding games (beginner, 38) and i was wondering how to make the movie clip do an animation for moving right or left or up or down after i press the keys for the movement. my code in the main time line for the actions layer looks like this:
watchKeyboard = new Object();
watchKeyBoard.onKeyDown = function() {
trace("a key is pressed. the key that is pressed is "+Key.getAscii());
};
Key.addListener(watchKeyBoard);
StageWidth = 600;
StageHeight = 400;
function moveStuff() {
if (Key.isDown(Key.LEFT)) {
this._x -= this.speed;
_root.man_mc;
gotoAndPlay(10);
}
if (Key.isDown(Key.RIGHT)) {
this._x += this.speed;
_root.box_mc;
gotoAndPlay(1);
}
if (Key.isDown(Key.UP)) {
this._y -= this.speed;
}
if (Key.isDown(Key.DOWN)) {
this._y += this.speed;
}
if (this._x>StageWidth+(this._width/2)) {
this._x = 0-(this._width/2);
}
if (this._x<0-(this._width/2)) {
this._x = StageWidth+(this._width/2);
}
if (this._y>StageHeight+(this._height/2)) {
this._y = 0-(this._height/2);
}
if (this._y<0-(this._height/2)) {
this._y = StageHeight+(this._height/2);
}
}
box_mc.speed = 5;
ball_mc.speed = 3;
box_mc.onEnterFrame = moveStuff;
ball_mc.onEnterFrame = moveStuff;
i = 0;
i = 0;
this.onEnterFrame = function() {
if (box_mc.hitTest(ball_mc._x, ball_mc._y)) {
newBall = ball_mc.duplicateMovieClip("ballCopy"+i, i++);
newBall._x = ball_mc._x;
newBall._y = ball_mc._y;
if (i>10) {
i = 0;
}
}
};
sorry bout the lenght... anyway if anyone could help it would be greatly appreciated. thanks
willbill is offline   Reply With Quote
Old 06-23-2003, 11:03 AM   #2
bluegel
Im watching in my absence
 
bluegel's Avatar
 
Join Date: Feb 2003
Location: wherever the mood takes me
Posts: 2,114
Default

can you upload a sample fla as it would be easier to help you this way, as there is a lot of code to tredge through

thanx
__________________
Im a girl

Watching in my absence - courtesy of CyanBlue
bluegel is offline   Reply With Quote
Old 06-23-2003, 11:44 AM   #3
spriggan
CyanBlue Groupie
 
spriggan's Avatar
 
Join Date: May 2002
Posts: 519
Default

Howdy Willbill (ack now you all have me doing it)

have a look at this thread

http://www.actionscript.org/forums/s...threadid=29309

it will show you how to do animation and movment with a key press.
spriggan is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:21 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.