-
[help] a few probs with scripting
This is my first flash game and I've looked, but couldn't find tutorials for the coding I want to do so I've been really struggling trying to guess where stuff goes and piecing individual tutorials together- I'm doing good but i have two problems:
1) when the laser hits the spaceship then you lose a life, when all lifes are gone then game over.
code: onClipEvent (load) {
var lives = 3;
function reset(){
this._y=-15;
this._x=random(400);
enemySpeed=random(10)+5;
}
reset();
}
onClipEvent (enterFrame) {
this._y+=enemySpeed;
if (this.hitTest( _root.spaceship ) ){
lives-=1
}
if (lives < 3) {
removeMovieClip(Life3);
}
if (lives < 2) {
removeMovieClip(Life2);
}
if (lives < 1) {
gotoAndPlay(517);
}
if (this._y>450) {
reset();
}
if (this.hitTest( _root.spaceship ) ){
removeMovieClip(this);
}
}
2) I have a power bar, I make it go up and down like I want but I can't make it go to the frames like it should.
code: onClipEvent(load){
dropSpeed=10;
upSpeed=3;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.CONTROL) and this._y<400) {
this._y+=dropSpeed;
} else if (Key.isDown(Key.SHIFT) and this._y>245) {
this._y-=upSpeed;
}
if (this._y>395) {
gotoAndPlay(118);
} else if (this._y<240) {
gotoAndPlay(211);
}
}
if someone could help me out with that or tell me how to make variables work please tell me because it seems like they don't do anything for me other than keep tract (I've already tried to switch frames based on score, but couldn't get it to even though scoring worked great)
-
code:
//lives
onClipEvent(load) {
lives = 3;
}
onClipEvent(enterFrame) {
if (this.hitTest(_root.laser)) {
lives --;
}
if (lives >= 0) {
_parent.gotoAndStop("lose");
}
}
-
-
well it does go to the frame but it jumps there immediately without the ship getting hit
-
thank you for the _parent. command, what i needed for my second problem so thanks for that though, still working on lives
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|