PDA

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

NTD
12-21-2004, 01:33 AM
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 &#40;load&#41; &#123;
speed = 5;
&#125;
onClipEvent &#40;enterFrame&#41; &#123;
if &#40;Key.isDown&#40;Key.UP&#41;&#41; &#123;
this.gotoAndStop&#40;"up"&#41;;
this._y -= speed;
&#125; else if &#40;Key.isDown&#40;Key.DOWN&#41;&#41; &#123;
this.gotoAndStop&#40;"down"&#41;;
this._y += speed;
&#125; else if &#40;Key.isDown&#40;Key.left&#41;&#41; &#123;
this.gotoAndStop&#40;"left"&#41;;
this._x -= speed;
&#125; else if &#40;Key.isDown&#40;Key.right&#41;&#41; &#123;
this.gotoAndStop&#40;"right"&#41;;
this._x += speed;
&#125;
&#125;


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&#40;&#41;&#123;
this._x=_root.ship._x;
this._y=_root.ship._y;
&#125;


The first method is probably preferable, as it will teach you more about moving objects with actionscript.

Hope it helps
NTD