View Full Version : Keeping Count and A Whole Bunch of Stuff
REEFˇ
01-11-2004, 05:24 PM
Ahoy Maties (wtf)...
It's not likely for me to ask a question on gaming since gaming is easy (except chess programming), but I would like to know a couple things. I have a billion methods of how to do them but I would like to know what the best way is. Since I will be making a tutorial soon, I want to have the best methods.
- First, 8-] I have 3 movieclips. The instances are lifeOne, lifeTwo, and lifeThree. Let's say I have 2 objects. How would I make it so if it touches one, a life is lost. Then if it touches it again or a different object, the next life is lost and so on.
: Thanks ;).
You mean? Kind-a like having a indication symbol somewhere that displays how many lives you have left?
The easiest and most proficient way is having only one movieClip and labelling it lives... Then you have the first frame have 1 life, second 2 lives and 3 three lives.. And you'd have them displayed in that correct order then.
Then a simple hitTest would conclude your results... Have a variable tracking the number of lives...
playerLives = 3;
function displayLives(numLives)
{
lives.gotoAndStop(numLives);
}
if(player.hitTest(enemy))
{
if(playerLives > 1)
{
playerLives--;
displayLives(playerLives);
}
else
{
displayLosingCredits();
}
}
Something along the lines of that...
REEFˇ
01-11-2004, 06:27 PM
Gotcha. But I was going in an easier and more powerful way by using lifeThree._visible = 0 and so on. Thanks. You'll see what I mean when I bring out my tut.
Dude... That's not very powerful.. The visible factor still means that the movieClip is drawn to screen in some way shape or form.. Meaning memory wise it's taking up space.. And for game programming.. That's a very bad idea... That's why I suggest the one movieClip idea... Plus having one movieClip vs 3 movieClips saves up on memory and space even more ;)
visible is better off in php and not Flash.. ;)
junahu
01-12-2004, 04:34 AM
You'll also want to add some kind of time out so all three lives don't end up vapourising symultaneously (of course I'm assuming everyone here already knew that, I'm just being picky).
The one movieclip idea is less processor intensive and less messy (3 X less code when refering to the graphical representation of lives). But multiple movieclips are more flexible (You can have each movieclip fall off the screen or fade out or something else wacky. Also any actionscripted-animation in the movieclips won't just reset suddenly when the number of lives changes.)
Originally posted by junahu
You'll also want to add some kind of time out so all three lives don't end up vapourising symultaneously (of course I'm assuming everyone here already knew that, I'm just being picky).
The one movieclip idea is less processor intensive and less messy (3 X less code when refering to the graphical representation of lives). But multiple movieclips are more flexible (You can have each movieclip fall off the screen or fade out or something else wacky. Also any actionscripted-animation in the movieclips won't just reset suddenly when the number of lives changes.)
You can still do that junahu.
You just have to sequence off the one movieClip easier.
Segment say... frames 1 through 5 as life one and 10 through 15 as life two and so on... It's really not that hard. :)
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.