Quick Links: Gideros Home | Download Gideros | Developer Guide
GTween an sprite using different easings
  • FavflyFavfly +1 -1
    Member
    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?
  • totebototebo +1 -1 (+1 / -0 )
    Member Accepted Answer
    You have to create a new GTween to do that.

    Likes: Favfly

    My Gideros games: www.totebo.com
  • FavflyFavfly +1 -1 (+2 / -0 )
    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

  • antixantix +1 -1 (+2 / -0 )
    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

    Check out my DevBlog, my GitHub, and my games Falling Animals | Breaky Wall | Exetor
  • FavflyFavfly +1 -1
    Member
    antix said:

    "...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 +1 -1 (+1 / -0 )
    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
  • antixantix +1 -1
    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.
    Check out my DevBlog, my GitHub, and my games Falling Animals | Breaky Wall | Exetor
  • rrraptor +1 -1
    Member
    antix said:

    @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 +1 -1
    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.
    Check out my DevBlog, my GitHub, and my games Falling Animals | Breaky Wall | Exetor
  • rrraptor +1 -1 (+1 / -0 )
    Member
    @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

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with OpenID

In this Discussion

Top Posters