ForumsProgramming ForumHelp plz

11 4174
forgottongaurdian
offline
forgottongaurdian
42 posts
Nomad

I'm looking for some one that knows how to add lives into flash...

at the momment i have everything set out. but i don't know how to add lives, save game, or customizable character.

if anyone knows how to do this plz post...

  • 11 Replies
NightfangII
offline
NightfangII
47 posts
Nomad

If you have a way for the player to die, add a variable called lives and make it so that when they die lives goes down by one (lives -= 1 and if lives is less than one, actually execute the code that kills them. If you want to have something happen when they lose a life put that in between <lives -= 1> and killing the player.
lives -= 1;
doSomethingWhenTheyLoseALife();
if (lives < 1) {
killPlayer();
}

As for saving, use SharedObjects.

As for customizable character, it really depends on how you programmed the character.

Programpro
offline
Programpro
562 posts
Nomad

yah, to make the lives a variable click on frame and say

var lives;

then, with the character, say

onClipEvent(load) {

_root.lives = whatever;

}

Nightfang covered everything else

forgottongaurdian
offline
forgottongaurdian
42 posts
Nomad

i have done what ya said and now my enermies wont come anymore...

NightfangII
offline
NightfangII
47 posts
Nomad

You enemies won't come anymore? How did you code the dying? And a better question, where did you encode the lives and dying?

Oh, and Programpro, I was thinking you would define the lives in the timeline on the frame (or frame before) you create the player.

forgottongaurdian
offline
forgottongaurdian
42 posts
Nomad

i put the coding in the whole frame.

Klaushouse
offline
Klaushouse
2,770 posts
Nomad

if(_root.char.hitTest(_root.evilthing)){
_root.lives -= 1;
_root.player.gotoAndPlay("YOURDEADNOW&quot;
_root.cry.gotoAndStop(2);
}

forgottongaurdian
offline
forgottongaurdian
42 posts
Nomad

thanks mate... but i have the lives set so you have 3... how would i code that?

NightfangII
offline
NightfangII
47 posts
Nomad

_root.lives = 5;

_root.onEnterFrame = function () {
if(_root.char.hitTest(_root.evilthing)){
_root.lives -= 1;
if (_root.lives < 1) {
_root.player.gotoAndPlay("YOURDEADNOW&quot;
_root.cry.gotoAndStop(2);
}
}
}

NightfangII
offline
NightfangII
47 posts
Nomad

oops meant 3 not 5, sorry.

_root.lives = 3;

not

_root.lives = 5;

forgottongaurdian
offline
forgottongaurdian
42 posts
Nomad

about the where did you put all the coding stuff... i looked into it and it's all in the accual movie clips...

forgottongaurdian
offline
forgottongaurdian
42 posts
Nomad

never mind i can't fix anything i'll just restart making it and when it comes time to add lives i'll come back here for help from you guys...

Showing 1-11 of 11