Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
feature suggestion — Gideros Forum

feature suggestion

alexzhengalexzheng Guru
edited October 2011 in General questions
easing function is a great feature for making animation, it would be much better if it support to pass a callback function and parameter to be called after the animation finished. For examle, when an enemy died,it plays a dying animation then call a function to do some cleanup job

for examle:
local mc = MovieClip.new{
{1, 100, sprite1, {x = {0, 200, "linear"}, callback, parameter},
{50, 150, sprite1, {y = {0, 100, "linear"}, {alpha = {0, 1, "easeOut"}},
{100, 200, sprite2, {x = {0, 200, "linear"}},
}

and
GTween.new(sprite, 2, {x = 240}, {delay = 0.2, ease = easing.outBounce, repeatCount = 2, reflect = true}, callback, parameter)

or use a action sequence such as cocos2d

Dislikes: atilim

+1 -1 (+0 / -1 )Share on Facebook

Comments

  • atilimatilim Maintainer
    edited October 2011
    For GTween you can do this. You have 2 options:

    1. By giving onInit, onChange and onComplete parameters:
    GTween.new(sprite, 2, {x = 240}, {onComplete = callback})
    2. By adding listener for "init", "change", and "complete" events
    local tween = GTween.new(sprite, 2, {x = 240})
    tween:addEventListener("complete", callback, parameter) -- here parameter is optional
    tween.dispatchEvents = true
    I don't have more information about action sequences but you can set nextTween field of a tween to cascade tweens:
    local tween1 = GTween.new(...)
    local tween2 = GTween.new(...)
    tween1.nextTween = tween2
    For MovieClip you're right. We're planning to improve MovieClip more.

    Thank you for suggestions :)
  • hi atilim
    thank you
    I got it
    EventDispatcher is a greate feature.
    does MovieClip dispatch some event after reach the specified frame


  • atilimatilim Maintainer
    Currently MovieClip doesn't support event dispatching. But we definitely improve it (with the next version) and add event dispatching capabilities.
  • hi atilim

    local tween1 = GTween.new(...)

    local tween2 = GTween.new(...)

    tween1.nextTween = tween2
    did you mean tween2 take place after tween1 is completed??

    I wirte the following code
    local tween = GTween.new(sprite, 0.1, {x = sprite:getX()+40}, {delay = 0, ease = easing.inoutElastic, repeatCount = 6, reflect = true})
    local tween2 = GTween.new(sprite, 0.1, {alpha = 0}, {delay = 0, ease = easing.inoutElastic, repeatCount = 6, reflect = true})
    tween.nextTween = tween2

    I seems tween and tween2 take palce simultaneously,just the same as without the line "tween.nextTween = tween2"

  • atilimatilim Maintainer
    You're right. I forgot to tell that you need to set tween2 paused:
    local tween = GTween(...)
    local tween2 = GTween(...)
    tween2:setPaused(true)
    tween.nextTween = tween2
  • atilimatilim Maintainer
    Also can you update your gtween.lua with this: http://dl.dropbox.com/u/684866/gtween.lua

    I've fixed a bug that can cause "invalid key to next"
  • @Atilim, is the eventListener automatically removed?
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • atilimatilim Maintainer
    edited April 2012
    @OZApps, when a GTween object completes, it's GCed and therefore its event listeners are removed.
Sign In or Register to comment.