I'm not confused, I know exactly what I'm doing. :-)
Here is what I've decided to do:
The user will call Animate.PositionX(Sprite, etc...) to start a new X position animation for a sprite. If I did not make that Create() function just now, then in the PositionX() function, I would have had to have:
Anim = New Animate
Anim.Link = AnimList.AddLast(Anim)
Which would have been just:
Anim = New Animate
AnimList.AddLast(Anim)
Except that I had forgotten to add the anim objects to the list, and it would not have required a third line as I thought it would to assign the new link to the type.
But anyway, the way I ended up doing it is cleaner. Now I don't even need that AnimList.AddLast(Anim) thing in each of those animation creation functions. I suppose I could even get rid of a whole MESS of default variable initialisations actually. Like um... Age = -1. Well maybe not that many. I guess I could change the create function to take some parameters though. Sprite, transform, time, flags, triggerdelaye, freesprite, startage, speed... All those could just be passed to the create function and I wouldn't have to assign them in every helper function.
Hmm.. I could even stick FreeTriggered in there. This will clean up the code significantly.
On second thought... I don't even want FreeTriggered there. That's a bug that has been in my AniBOB system I guess. Now that I think about it, that is not a good idea now that there is a trigger delay in the two systems. That means an animation playing currently would be shut off immediately if you add one to the queue, even if the new one doesn't trigger immediately. The update function should delete those triggered anims properly so this isn't even needed here. I think.
Here is what I've decided to do:
' ------------------------------------------------------------------------------------------------------------------------------------------------------- ' This function creates a new Animate instance. You should not need to call it. ' ------------------------------------------------------------------------------------------------------------------------------------------------------- Function Create:Animate() Local Anim:Animate ' Create a new Animate instance. Anim = New Animate ' Add it to the end of the AnimList, and save a pointer to the link created. Anim.Link = AnimList.AddLast(Anim) ' Return the pointer to the new Animate instance. Return Anim End Function ' ------------------------------------------------------------------------------------------------------------------------------------------------------- ' This function moves a BOB from one X position to another, over time. ' ' You may run both X and Y position animations simulataneously and with different parameters. Keep in mind though that specifying a new PositionX() animation will only ' override the X component of a previously applied Position() animation. Same for PositionY(). ' ' You can use PositionX() and PositionY() seperately with different settings to do advanced effects like text moving in a sine wave across the screen. ' ------------------------------------------------------------------------------------------------------------------------------------------------------- Function PositionX(ThisSprite:Sprite, StartX#, EndX#, Time, Flags=0, TriggerDelay=0, FreeSprite=False, StartAge=0) Local Anim:Animate FreeTriggered(ThisSprite, ANIM_POSITIONX) Anim = Animate.Create() Anim.Sprite = ThisSprite Anim.Transform = ANIM_POSITIONX Anim.StartX# = StartX# Anim.EndX# = EndX# Anim.Time = Time Anim.Flags = Flags Anim.Age = -1 Anim.TriggerDelay = TriggerDelay Anim.FreeSprite = FreeSprite Anim.StartAge = StartAge Anim.Speed# = 1.0 Update() End Function
The user will call Animate.PositionX(Sprite, etc...) to start a new X position animation for a sprite. If I did not make that Create() function just now, then in the PositionX() function, I would have had to have:
Anim = New Animate
Anim.Link = AnimList.AddLast(Anim)
Which would have been just:
Anim = New Animate
AnimList.AddLast(Anim)
Except that I had forgotten to add the anim objects to the list, and it would not have required a third line as I thought it would to assign the new link to the type.
But anyway, the way I ended up doing it is cleaner. Now I don't even need that AnimList.AddLast(Anim) thing in each of those animation creation functions. I suppose I could even get rid of a whole MESS of default variable initialisations actually. Like um... Age = -1. Well maybe not that many. I guess I could change the create function to take some parameters though. Sprite, transform, time, flags, triggerdelaye, freesprite, startage, speed... All those could just be passed to the create function and I wouldn't have to assign them in every helper function.
Hmm.. I could even stick FreeTriggered in there. This will clean up the code significantly.
On second thought... I don't even want FreeTriggered there. That's a bug that has been in my AniBOB system I guess. Now that I think about it, that is not a good idea now that there is a trigger delay in the two systems. That means an animation playing currently would be shut off immediately if you add one to the queue, even if the new one doesn't trigger immediately. The update function should delete those triggered anims properly so this isn't even needed here. I think.