Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
GTween an sprite using different easings — Gideros Forum

GTween an sprite using different easings

FavflyFavfly Member
edited July 2017 in General questions
I’ve created a MovieClip sprite that repeats an animation over and over. I want to move that sprite from one place on screen to another. I’ve achieved that with the following gtween.
GTween.new(animatingMovClip, 2, {x = xPos, y = yPos}, {ease = easing.inQuadratic})
However, I want to alter the sprite’s alpha over the course of that move, but not using easing.inQuadratic - I’d like it to use a different easing. How do I do that?

Comments

  • totebototebo Member
    Accepted Answer
    You have to create a new GTween to do that.

    Likes: Favfly

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • FavflyFavfly Member
    Lol! That was easy. :-D

    I'm new to GTween. I've been using MovieClip, which is great... but now seems a lot slower the GTween.

    Thanks.

    Likes: totebo, antix

    +1 -1 (+2 / -0 )Share on Facebook
  • antixantix Member
    @FavFly just be aware that GTween will really suck CPU resources when you use a lot of them. It really needs a rewrite to not be an EventDispatcher to make it perform better. Use it sparingly and you will be fine :)

    Likes: Favfly, totebo

    +1 -1 (+2 / -0 )Share on Facebook
  • FavflyFavfly Member
    "...GTween will really suck CPU resources when you use a lot of them."
    Out of interest, how many is too many? ...Or is it just a case of 'you'll know when it's too many'? :-D
  • totebototebo Member
    Do a test and see what works for you. I find MovieClip to be (much) faster, but it may depend on how you use them. Maybe the creation is the bottleneck and you need to pool GTweens or MovieClips.

    Likes: antix

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • antixantix Member
    Yes the bottleneck is usually the creation and yes, a pool of them would be more efficient and then in the worst case scenario create new ones if the pool is depleted.

    It could possibly be rewritten to use a single EnterFrame event to process a table of all currently running tweens too.
  • rrraptorrrraptor Member
    edited July 2017
    @FavFly just be aware that GTween will really suck CPU resources when you use a lot of them. It really needs a rewrite to not be an EventDispatcher to make it perform better. Use it sparingly and you will be fine :)
    :-?
    Im using this construction:
    function animateSprite(sprite, target, duration, ease)
    	if (sprite.gt) then
    		sprite.gt:setValues(target)
    		sprite.gt:setDuration(duration or 1)
    		sprite.gt:setEase(ease or easing.linear)
    		sprite.gt:setPaused(false)
    	else
    		sprite.gt = GTween.new(sprite, duration or 1, target, {ease = ease or easing.linear})
    	end
    end
    Is it enough to maintain 54 animations at the same time (init animation and level restart animation)?

    I was trying to do same thing with MovieClip, but there is no setters... you can only create new one. And i don't really like frame binding instead of time duration, but if it is more effective, then I will have to use it.
  • antixantix Member
    @rrraptor it all depends on what it will run on. You should make a worst case scenario (so 54 or more) and see how it runs on your target device.

    I have an old Nexus4 phone as my lowest target device.
  • rrraptorrrraptor Member
    edited July 2017
    @antix so, i made a quick test on Samsung Galaxy S GT-S7562 (1GHz, 756 mb RAM, snap MSM7227A). Everything works perfect, no lags, all animations is smooth, so i think that GTween is pretty good, at least for my purposes.

    Likes: antix

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.