Posted: 28th Aug 2021 20:42
I've never really played with tweens befoer and got around to noodling around with them this week and I can definitely see a million fun applications for them. I've toyed with them a bit, read the documentation and I think I got most of it. I've got two questions that I didn't find a hint for in the help file:

1) Are tween coordinates always absolute or is there a way to make them dynamic? For example: SetTweenSpriteX(tweenID, 0,200,0), 0 and 200 are absolute values. This would move my sprite from 0 to 200. But if my sprite was at 150, it wouldn't move it 150 > 350, it would still move it 0 > 200. I haven't found any way to make tweens dynamic. Well I mean.. I can just create a tween on the fly when I need it I guess, then all my Get commands would return current data.. but any way to pre-define such tweens?

2) Is there a way to loop a tween? or a chain? Seems to me it would be useful.
Posted: 28th Aug 2021 21:08
1. I am pretty sure Tween coords are world coords, you can make them dynamic or local with :

+ Code Snippet
function spriteToWorldX(spr,x#,y#)

       rem get sprite data

       a# = getSpriteAngle(spr)

       ox# = getSpriteXbyOffset(spr)

       

       rem get display data

       dw# = getVirtualWidth()

       dh# = getVirtualHeight()

       aspect# = (dw# / dh#)

       if aspect# = 1.0

               scaleX# = getSpriteWidth(spr)/100.0

               aspect# = getDisplayAspect()

               scaleY# = scaleX# * aspect#

       else

               aspect# = 1.0

               i = getSpriteImageID(spr)

               scaleX# = getSpriteWidth(spr)/getImageWidth(i)

               scaleY# = getSpriteHeight(spr)/getImageHeight(i)

       endif

       

       rem calculate value

       dx# = cos(a#) * (x# * scaleX#) - sin(a#) * (y# * scaleY#)

       wx# = ox# + dx#

endfunction wx#
function spriteToWorldY(spr,x#,y#)

       rem get sprite data

       a# = getSpriteAngle(spr)

       oy# = getSpriteYbyOffset(spr)

       

       rem get display data

       dw# = getVirtualWidth()

       dh# = getVirtualHeight()

       aspect# = (dw# / dh#)

       if aspect# = 1.0

               scaleX# = getSpriteWidth(spr)/100.0

               aspect# = getDisplayAspect()

               scaleY# = scaleX# * aspect#

       else

               aspect# = 1.0

               i = getSpriteImageID(spr)

               scaleX# = getSpriteWidth(spr)/getImageWidth(i)

               scaleY# = getSpriteHeight(spr)/getImageHeight(i)

       endif

   

       rem calculate value

       dy# = sin(a#) * (x# * scaleX#) + cos(a#) * (y# * scaleY#)

       wy# = oy# + dy# * aspect#

endfunction wy#


^^ from UCF project: https://forum.thegamecreators.com/outbound?url=https%3A%2F%2Fforumfiles.thegamecreators.com%2Fdownload%2F2334782

2. not sure, I will be looking at soon, I think it might be a case of checking if the tween has finished and play it again

Am going to use this in my CodeJam project but knee deep in GIMP at mo... and being a man I cant multitask...LOL
Posted: 29th Aug 2021 14:07
1. Tweens are absolute you would have to make it on the fly. You could create a function that would do it for you based on the current values though.
2. There's no auto loop (shame really - it would be useful) but you can check to see if a tween has stopped playing and restart it if it has.
Posted: 2nd Sep 2021 23:41
Aye that's what I ended up doing, I just gather all the info I need for my tween and create it right before using it. Feels a bit counter intuitive to me, but it's easy to work around it at least. Still though, it seems to me that dynamic tweens could be super useful.

Am going to use this in my CodeJam project but knee deep in GIMP at mo... and being a man I cant multitask...LOL

Sure you can. You can multitask, just....one task at a time, that's all. I call it sequential multitasking.
Posted: 3rd Sep 2021 0:18
LMAFO, like consecutively concurrent

... That's to much like "Double Speak" for my liking ... just got a shiver down my spine!
Posted: 3rd Sep 2021 6:17
Various types of easing calculations