Question

I'm trying a GTween example from the following link

Gideros GTween with Easing

The example doesn't work out of the box, so I dug into the source code of GTween and added the following lines to my example in order to allow event dispatching.

local tween = GTween.new(jewel, 2, animProperties, gtweenProperties)
tween.suppressEvents = false -- New Line #1
tween.dispatchEvents = true  -- New Line #2
tween:addEventListener('complete', function()
    stage:removeChild(jewel)
    jewel = nil
end)

However, the app crashes. I tried commenting the following line in gtween.lua

self:dispatchEvent(Event.new(name))

and the app doesn't crash, however the callbacks aren't invoked (obviously, why would it?)

This is the stack trace from the app.

gtween.lua:445: attempt to call method 'dispatchEvent' (a boolean value)
stack traceback:
    gtween.lua:445: in function 'dispatchEvt'
    gtween.lua:255: in function 'setPosition'
    gtween.lua:86: in function <gtween.lua:74>

Any pointers would be greatly appreciated. Thanks.

PS: I'm not sure if this is a bug on Gideros.

Was it helpful?

Solution

i just tried with the latest gideros' gtween (note that it is edited 10 days ago), and use this sample (i took the sample from your link and add sprite definition, also include a image file in project) and it works(the callback is called) :

local animate = {}
animate.y = 100
animate.x = 100
animate.alpha = 0.5
animate.scaleX = 0.5
animate.scaleY = 0.5
animate.rotation = math.random(0, 360)
local properties = {}
properties.delay = 0
properties.ease = easing.inElastic
properties.dispatchEvents = true

local sprite = Bitmap.new(Texture.new("box.png"))  -- ADD THIS
stage:addChild(sprite) -- ADD THIS
local tween = GTween.new(sprite, 10, animate, properties)

tween:addEventListener("complete", function()
    stage:removeChild(sprite)
    sprite = nil
end)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top