Animindex problem

Non-platform specific questions.

Animindex problem

Postby Freddy » Mon Aug 06, 2007 3:21 pm

I'm working on my game X-Terminator, and I created a bug count for every bug you kill. I used the mouse button down event, bugs = bugs + 1;. The insects have two multi-file animations; walking left, and a dying twitch. When the ants are squashed, the bug count goes up a digit, and the ants dying twitch animation lasts for the remainder of the level. Then all the remaining ants are destroyed. However, I noticed that if you click on the ants, when they are on their dying twitch animation, the bug count is increased. To stop this I changed the, bugs = bugs + 1;, to
if(animindex ==0)
{
bugs = bugs + 1;
}
But when I clicked the ants, the bug count didnt increase at all, even when the ants had their dying twitch animation. So I changed it to
if(animindex ==1)
{
bugs = bugs + 1;
}
But this time, when I clicked, the bug count not only increased when the ants were walking, but it increased when they were twitching too. I also tried putting in this script,
if(animindex !=1)
{
bugs = bugs + 1;
}
But it had the same results as the first alteration I made. I also tried the opposite of this;
if(animindex!=0)
{
bugs = bugs + 1;
}
But it had just the same effect as the second alteration I made to the code. If anyone knows how to make the bugcount increase by 1, only when the ants animation is walking left, I'd be glad to know.
8)
Hola
User avatar
Freddy
 
Posts: 548
Joined: Sat Jun 02, 2007 3:42 pm
Location: Why do you want to know?
Score: 14 Give a positive score

Postby d-soldier » Mon Aug 06, 2007 3:31 pm

Is the mouse-button-down event linked to the of the bugs itself? If so, simple make a variable called "living" and change it from "global" to "actor", and then in the create-actor script for each of you bug actors, put:

living=1;

and then in the script which which changes their animation after being hit, put:

living=0;

and then on the click-down event put:

if (living==1)
{
bugs = bugs + 1;
}

that ought to do it.. not sure why you were having problems with the animindex statement...
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby Freddy » Mon Aug 06, 2007 3:37 pm

I'll try it out, thanks :D
Hola
User avatar
Freddy
 
Posts: 548
Joined: Sat Jun 02, 2007 3:42 pm
Location: Why do you want to know?
Score: 14 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron