It looks like you're new here. If you want to get involved, click one of these buttons!
orxBOOL Ammo::OnCollide(ScrollObject *collider, const orxCHAR *partName, const orxVECTOR &position, const orxVECTOR &normal)
{
/* just die */
SetLifeTime(orxFLOAT_0);
SetAnim("ExplosionAnimSet"); // trigger animation
return orxTRUE;
}
[ExplostionAnimSet]
AnimationList = ExplosionAnim
LinkList = ExplosionLink
[ExplosionLink]
Source = ExplosionAnim
Destination = ExplosionAnim
[ExplosionAnim]
DefaultKeyDuration = 0.1
KeyData1 = Explosion0
KeyData2 = Explosion1
KeyData3 = Explosion2
[Explosion]
[Explosion0@Explosion]
Texture = explosion0.png
[Explosion1@Explosion]
Texture = explosion1.png
[Explosion2@Explosion]
Texture = explosion2.png
Comments
- If you delete your object at the same time you set an anim on it, you won't be able to see it.
- You have a typo in ExplostionAnimSet, did you do the same when referencing it from your object?
- You should add a second animation, Idle, which would just be one frame and would loop on itself, this way you can have a real anim graph: idle->idle, idle->explosion, explosion->idle.
- You can do your SetLifeTime(0) when handling the new animation (explosion->idle) or by adding a custom event somewhere in your animation and using OnNewAnim()/OnAnimEvent: this way, even if the length of your anim changes, your Ammo object will always be deleted at the right time.
Here is how I understand it. The AnimationSet has to be defined before the actual animation can be used. So, in my case I have only 2 states: idle and explosion, but 3 transitions: idle-to-idle, idle-to-explosion and explosion-to-idle. I have to define the AnimationSet with animations and valid transitions (links) between animations. The 1st animation in the set is the default one.
What is the difference between orxObject_SetTargetAnim and orxObject_SetCurrentAnim?
I think that one changes abruptly and the other uses links to change animation from one to another thus it should result in a smooth animation transition from one state to another.
Unfortunately I am now getting an error on application exit. If I comment out the line:
AnimationSet = ExplosionAnimSet
the error on exit does not occur.
I really don't do much with bullets. I create bullets, react on collision with the bullet and that's it. My object's method on collision takes the hit damage and and the bullet simply goes away. I obviously need to start using events to dispose of the bullet instead of SetLifeTime(3.), but I don't think it is what causes the error listed below.
Error:
I like that orx is capable of detecting that higher level code made a mistake. It caught me a few times already. I think this is another case of object reference being kept after the object was destroyed by orx.
My code:
Config file:
And yes, you're correct for SetTargetAnim/SetCurrentAnim: the target will set a "destination" on the graph and try to follow the links that will bring us there, raising all the encountered events in the process, whereas the current version will just "teleport" us to that node of the graph, no matter if it was reachable or not in the first place.
I am running "turns".
At the moment the explosion animation has 16 images and thus it should take 1.6 seconds, but it may get paused and I've seen it paused in the middle. May this be an issue?
I only see 3 frames in your config for the explosion, so I guess it's not the same version?
When did you notice the animation get paused? If you pause the game, that should happen (there's a config property Pausable if you want some objects not being affected by Scroll::Pause()).
Otherwise it might be an issue somewhere either in your game or on orx's side.
If you share your project with me, I can have a look if you want, that should be easier than doing it with snippets over the forum.
Yes, I saw Scroll had its own copy of includes. I did not consume that.
All I have to do is start application, it displays a dot. Animation is not even getting triggered on the visual side. Quit application (I use Cmd-Q) and I get the reported error.
The bitbucket public project that demonstrates the issue is here:
https://bitbucket.org/Kulak/testanimationinscroll
I have changed the project to public and allowed forks.
What I did is simply launch, see there's a dot being displayed and quit by pressing the 'X' button in both debug & release.
I'll have to try it on OS X this week end, but I'd be surprised if it were a platform dependent issue given the callstack.
Just in case, could you double check your libraries (both compile time and runtime) are in sync with your headers?
However, after I have rebuilt orx and scroll copies I no longer have an issue in the test project.
I guess my original project configuration was messed up somehow.