我正在尝试以下链接中的GTween示例
Gideros GTween with Easing
该示例无法开箱即用,因此我深入研究了GTween的源代码,并在示例中添加了以下几行代码,以便允许事件分派。
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)然而,应用程序崩溃了。我尝试在gtween.lua中注释下面这行
self:dispatchEvent(Event.new(name))应用程序不会崩溃,但是回调函数没有被调用(显然,它为什么会被调用呢?)
这是来自应用程序的堆栈跟踪。
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>如果有任何建议,我们将非常感谢。谢谢。
PS:我不确定这是不是Gideros上的一个bug。
发布于 2013-04-19 19:20:50
我刚刚尝试了最新的gideros的gtween (注意,它是在10天前编辑的),并使用这个示例(我从您的链接中获取了示例,并添加了sprite定义,还在项目中包含了一个图像文件),它可以工作(回调为):
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)https://stackoverflow.com/questions/15942596
复制相似问题