Sorry guys, it was my fault. I'm not an expert, so I just took a short look over the code, then I quickly tried it.
I thought that it's certainly good, so I have time to understand it later. Then I saw that the animation-changes triggered by pressing keys, and I thought that Sudi may have misunderstood my problem.
Now I see that was my mistake, sorry for that, and thanks again for your spent time and efforts!
Sudi wrote:
Just as an example you could add a next field to each animation and when set it plays this next animation when the animation finishes.....
Yes, it works of course.
Now I'm trying to simplify your code for at least one and a half hour, but I can achieve only, what I've done before..
You may ask why am I doing this, but my program structure is much more simplier than yours (only one file, main.cpp and only the main function,the shooting function and the eventreceiver so far), and I want to keep that form to be easily overviewed by beginners like me.
Here's what I tried:
In Shooting function, after checking if the enemy takes hit, I want to call the new functions like this:
Code: Select all
playanimation(1); // takes hit
onanimationend(); // I want to end that animation
playanimation(2); // walks
playanimation:
Code: Select all
void playanimation(int n)
{
if(n==1)
{
if(!animationrunning) // animationrunning is a global variable, starting value is false
{
setanimation(1);
}
else
{
//hasnext=true; // hasnext is a global variable, starting value is false
//setanimation(2);
}
}
else if(n==2)
{
if(!animationrunning)
{
setanimation(2);
}
else
{
//
}
}
}
setanimation:
Code: Select all
void setanimation(int n)
{
if(n==1)
{
node->setFrameLoop(272,288);
node->setLoopMode(false);
animationrunning=true;
}
else if(n==2)
{
node->setFrameLoop(0,24);
node->setLoopMode(true);
animationrunning=true;
}
}
onanimationend:
Code: Select all
void onanimationend()
{
if(animationrunning)
{
node->setAnimationEndCallback(0); // I want to end that animation
animationrunning=false;
}
else
{
}
}
I know this code misses a lot from yours, but I tried a lot of things, but I REALLY can't get this to work in this way
I'm completely confused, embittered, I can't proceed in my work for days now because of this!
It could be so easy if these frameloops could go into a queue: if one finished, the others start, why can't be like this?
I think you're already tired of me, but if someone have pity on me, please help. Thank you..