Page 1 of 1

Animindex problem

PostPosted: Mon Aug 06, 2007 3:21 pm
by Freddy
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)

PostPosted: Mon Aug 06, 2007 3:31 pm
by d-soldier
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...

PostPosted: Mon Aug 06, 2007 3:37 pm
by Freddy
I'll try it out, thanks :D