Be a Supporter!

Help With Hittest And Dynamic Text!

  • 253 Views
  • 7 Replies
New Topic Respond to this Topic
crayzrocker
crayzrocker
  • Member since: Oct. 31, 2008
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Help With Hittest And Dynamic Text! 2008-12-03 07:17:38 Reply

Hello

I have a script that, when my moviclip hits the walls, it subtracts 1 from the amount of lives that the player has.

In the beginning, when the game starts, the player has 3 lives.

So far, everything works fine.

But now i would like a script, so that when the amount of lives is 0, it goes to another frame which sais you lost.

This is the current code i am using, but it doesnt work:

if(_root.lives==0){
gotoAndStop(2)
}

The dynamic text box has the var name of "lives".

Can someone please point out to me what exactly am i doing wrong?

Thanks in advance
crayzrocker

crayzrocker
crayzrocker
  • Member since: Oct. 31, 2008
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to Help With Hittest And Dynamic Text! 2008-12-03 07:52:26 Reply

Does no one know how to do this???

Sorry for the double post...

Trunks-Lock
Trunks-Lock
  • Member since: May. 6, 2005
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Help With Hittest And Dynamic Text! 2008-12-03 07:54:06 Reply

Can you try taking away _root and post how that works out?


Gamemaker in Training.

crayzrocker
crayzrocker
  • Member since: Oct. 31, 2008
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to Help With Hittest And Dynamic Text! 2008-12-03 08:08:04 Reply

At 12/3/08 07:54 AM, Trunks-Lock wrote: Can you try taking away _root and post how that works out?

Nope, still does not work.

Help?

Trunks-Lock
Trunks-Lock
  • Member since: May. 6, 2005
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Help With Hittest And Dynamic Text! 2008-12-03 08:11:46 Reply

I think I found the problem.

if(_root.lives==0){
gotoAndStop(2)
}

You missed an ; behind gotoAndStop(2).
So it should be:
if(_root.lives==0){
gotoAndStop(2);
}


Gamemaker in Training.

crayzrocker
crayzrocker
  • Member since: Oct. 31, 2008
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to Help With Hittest And Dynamic Text! 2008-12-03 08:16:22 Reply

Nope it doesnt work...

Trunks-Lock
Trunks-Lock
  • Member since: May. 6, 2005
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Help With Hittest And Dynamic Text! 2008-12-03 08:26:15 Reply

Alright, here's an example of what I used ( year old stuff so AS2 ) :
if(body>0)
{
body-=5;

}
else
{
disableObjects();
gotoAndStop(3);
}
There's a timer around it, so it checks every frame if body > 0.
But this works for me.


Gamemaker in Training.

uyersuyer
uyersuyer
  • Member since: May. 15, 2002
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Help With Hittest And Dynamic Text! 2008-12-03 11:28:42 Reply

If you're putting that on the main timeline, it won't work because it'll only check it once (when the game first starts). What you want is:

onEnterFrame = function () {
if(_root.lives==0){
_root.gotoAndStop(2);
}
}

"Whoever said 'winners never quit' obviously never considered addicts." - Hoeloe

BBS Signature