View Full Version : need some help *kindof* a game
teeebaum
12-20-2004, 10:30 PM
I am trying to make this, sort of game. I have a triangle figure that i put a movie clp into. The movieclip shows the figure go to the left with a button --> on (keyPress "<Left>") {play();} . I did the same with a spacebar shooting movieclip,(when i press the spacebar it shoots from a movieclip). What I am having trouble with is that i cant shoot (using the spacebar) when i am in the "move left" movie clip". Since i am 13 years old and i have only 4 months of experience with flash, this is the most logical way i can see makin a flash game. please help!
Thanx,
tEEbaum
Hi,
It sounds as if you have used motion tweens to move the clip. Couple things you can do is to move your clip with actionscript instead or put the clip in a holder movieclip and give your shooting action to the holder movieclip.
The first method....
This method assumes that you have a movieclip with four frames representing up,down,left, and right. It allows for motion in any direction. You could change it to whatever you need. I generally use frame code, but this might be easier to understand as object code. Create a movieclip with the above mentioned (labeled)frames and paste this code onto it...
onClipEvent (load) {
speed = 5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
this.gotoAndStop("up");
this._y -= speed;
} else if (Key.isDown(Key.DOWN)) {
this.gotoAndStop("down");
this._y += speed;
} else if (Key.isDown(Key.left)) {
this.gotoAndStop("left");
this._x -= speed;
} else if (Key.isDown(Key.right)) {
this.gotoAndStop("right");
this._x += speed;
}
}
The holder method is pretty straight forward. Place your movieclip with the tween inside a holder movieclip and give the holder movieclip your fire method. Then put some code in to keep the holder movieclip at the same coordinates as the "ship" movieclip...
_root.holderMC.onEnterFrame=function(){
this._x=_root.ship._x;
this._y=_root.ship._y;
}
The first method is probably preferable, as it will teach you more about moving objects with actionscript.
Hope it helps
NTD
Powered by vBulletin™ Version 4.1.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.