I had stuff working before I went from 1076 to 1177, and now it seems like Runtime:dispatchEvent(…) isn’t sending the event.
Not exactly sure what is happening. Just wanted to mention it. Will see if it’s something I accidentally did.
I had stuff working before I went from 1076 to 1177, and now it seems like Runtime:dispatchEvent(…) isn’t sending the event.
Not exactly sure what is happening. Just wanted to mention it. Will see if it’s something I accidentally did.
Verified that if i build with 1076 and 1137. 1037 wont send/handle the Runtime:dispatchEvent and 1076 will.
Tested a bunch of daily builds to find the culprit.
Something changed from build 1089 and 1092 to break my Runtime:dispatchEvent(…) call.
Can someone check and verify this?
Ok, this little test works with build 1092.
Need to figure out exactly why calling a runtime:dispatchEvent in my code isn’t working. I suspect it has to do with storyboard scenes.
local transition = require "transition" local block = display.newImage("images/object.png") block.x, block.y = display.contentWidth\*0.5, display.contentHeight\*0.5 local function rotateBlock(event) transition.to(block, {time=1000, rotation=block.rotation+360}) end local function onSystemEvent( event ) if event.type == "applicationStart" then elseif event.type == "applicationExit" then elseif event.type == "applicationSuspend" then elseif event.type == "applicationResume" then Runtime:dispatchEvent{ name = "rotateBlock" } end end Runtime:addEventListener( "rotateBlock", rotateBlock) Runtime:addEventListener( "system", onSystemEvent )
Nope. Not storyboard. This test works too.
main.lua:
local storyboard = require "storyboard" local function onSystemEvent( event ) if event.type == "applicationStart" then elseif event.type == "applicationExit" then elseif event.type == "applicationSuspend" then elseif event.type == "applicationResume" then Runtime:dispatchEvent{ name = "rotateBlock" } end end Runtime:addEventListener( "system", onSystemEvent ) storyboard.gotoScene("menu")
menu.lua:
local storyboard = require "storyboard" local transition = require "transition" local scene = storyboard.newScene() local block local function rotateBlock(event) transition.to(block, {time=1000, rotation=block.rotation+360}) end function scene:enterScene( event ) local screenGroup = self.view block = display.newImage("images/ground3.png") screenGroup:insert(block) block.x, block.y = display.contentWidth\*0.5, display.contentHeight\*0.5 Runtime:addEventListener( "rotateBlock", rotateBlock ) end -- CREATE SCENE: INIT function scene:createScene( event ) end function scene:willEnterScene( event ) end function scene:destroyScene( event ) end function scene:willExitScene( event ) end function scene:exitScene( event ) Runtime:removeEventListener("rotateBlock", rotateBlock) end -- Init storyboard listeners scene:addEventListener( "createScene" ) scene:addEventListener( "destroyScene" ) scene:addEventListener( "willExitScene" ) scene:addEventListener( "exitScene" ) scene:addEventListener( "willEnterScene" ) scene:addEventListener( "enterScene" ) return scene
OK! I’m an idiot! Which was the most likely scenario to begin with.
But… the problem was buried. So I had to Encyclopedia Brown it up.
Turns out you can do this in 1089
object.removeSelf()
But you are forced to do this in 1092
object:removeSelf()
Not sure why the . version was even working in the first place.
Verified that if i build with 1076 and 1137. 1037 wont send/handle the Runtime:dispatchEvent and 1076 will.
Tested a bunch of daily builds to find the culprit.
Something changed from build 1089 and 1092 to break my Runtime:dispatchEvent(…) call.
Can someone check and verify this?
Ok, this little test works with build 1092.
Need to figure out exactly why calling a runtime:dispatchEvent in my code isn’t working. I suspect it has to do with storyboard scenes.
local transition = require "transition" local block = display.newImage("images/object.png") block.x, block.y = display.contentWidth\*0.5, display.contentHeight\*0.5 local function rotateBlock(event) transition.to(block, {time=1000, rotation=block.rotation+360}) end local function onSystemEvent( event ) if event.type == "applicationStart" then elseif event.type == "applicationExit" then elseif event.type == "applicationSuspend" then elseif event.type == "applicationResume" then Runtime:dispatchEvent{ name = "rotateBlock" } end end Runtime:addEventListener( "rotateBlock", rotateBlock) Runtime:addEventListener( "system", onSystemEvent )
Nope. Not storyboard. This test works too.
main.lua:
local storyboard = require "storyboard" local function onSystemEvent( event ) if event.type == "applicationStart" then elseif event.type == "applicationExit" then elseif event.type == "applicationSuspend" then elseif event.type == "applicationResume" then Runtime:dispatchEvent{ name = "rotateBlock" } end end Runtime:addEventListener( "system", onSystemEvent ) storyboard.gotoScene("menu")
menu.lua:
local storyboard = require "storyboard" local transition = require "transition" local scene = storyboard.newScene() local block local function rotateBlock(event) transition.to(block, {time=1000, rotation=block.rotation+360}) end function scene:enterScene( event ) local screenGroup = self.view block = display.newImage("images/ground3.png") screenGroup:insert(block) block.x, block.y = display.contentWidth\*0.5, display.contentHeight\*0.5 Runtime:addEventListener( "rotateBlock", rotateBlock ) end -- CREATE SCENE: INIT function scene:createScene( event ) end function scene:willEnterScene( event ) end function scene:destroyScene( event ) end function scene:willExitScene( event ) end function scene:exitScene( event ) Runtime:removeEventListener("rotateBlock", rotateBlock) end -- Init storyboard listeners scene:addEventListener( "createScene" ) scene:addEventListener( "destroyScene" ) scene:addEventListener( "willExitScene" ) scene:addEventListener( "exitScene" ) scene:addEventListener( "willEnterScene" ) scene:addEventListener( "enterScene" ) return scene
OK! I’m an idiot! Which was the most likely scenario to begin with.
But… the problem was buried. So I had to Encyclopedia Brown it up.
Turns out you can do this in 1089
object.removeSelf()
But you are forced to do this in 1092
object:removeSelf()
Not sure why the . version was even working in the first place.