Greetings to all members!
Please, i am facing some basic challenge, which is getting me more confused with corona. Although i have encountered several challenges all this while, with which for some of them i manage to get them in place, but unfortunately not this one.
The issue this time is, i have created a module which enables me to create a tree object, and even with several options of showing connecting lines, changing background colour, among others. Everything works so normal, when i call a function in the “On touch” event of an object, without any errors or whatsoever, but unfortunately, when i try to call the function under scene “On will” event, nothing happens. I taught is because in the function i made it to execute the action in the touch ended event, but i have tried changing it, and among other test even changed phase detection to “ended” or “will”, but still is not responding under the scene “will” event. Please, is there something i have to do when calling the function under scene “will” that may be different from the touch event?, please help me!!!
Thanks so much in advance.
Hi.
Before answering, let me ask you do the following:
- Please do not use ALL CAPS in titles. This is the electronic equivalent of shouting and some find it very off-putting.
- Please use paragraphs and other elements to make your future posts legible. One big mind-dump it semi-impenetrable and folks will not bother to read or answer it.
- While we appreciate your struggle and background, please just ask the question or at least separate out the salient bits, so we can get right to answering/helping.
Now, digging through the question… so it sounds like you’re having trouble with a touch handler and executing code in the show() method of a composer scene?
Please post the touch handler code and the code in your show() method, use code blocks, and take time to format for legibility without altering the code from what you’ve got.
Ex:
local function onTouch( event ) if( event.phase == "began" ) then end return false end
function scene:show( event ) local sceneGroup = self.view local willDid = event.phase if( willDid == "will" ) then elseif( willDid == "did" ) then end end
@ roaminggamer
First of all thanks for the directives and suggestions. I duly appreciate that. Thanks so much.
Now please, here is what I have for my touch handler code and the code on my OnShow event:
function page:show( event )
local pageComponent = self.view
local phase = event.phase
if ( phase == “will” ) then
local function handleMyTree(e)
if e.phase == “ended” then
myTree.onTreeButPress(appTreeData, {trObjArrayName = “Item 1”,
showLinks = true,
xPos = 100,
yPos = 100,
width = 25,
height = 12,
bounds = false,
OptColor = {0.98, 0.88, 0.98}
})
end
return true
end
tmrtreeshow = timer.performWithDelay( 500, handleMyTree, 1 )
Runtime:addEventListener( “touch”, handleMyTree )
elseif ( phase == “did” ) then
end
end
And the problem is I want the function to trigger automatically, before the scene shows, but neither the runtime listener nor the timer is able to trigger the function to work.
Thanks once again!
Oh please! No one will help me!
I am getting confused. I just don’t know why the script in the module gets compiled and run on a button event listener (I mean when I touch the button, everything works fine without any issues), but doesn’t work when i try calling the module function directly on a scene ‘will’ event, and doesn’t attach it to any listener. My code is too many, I would have posted it here!
Forgive me for my English expressions if I don’t sound clearly.
Please, I beg all members, sombody should just suggest possible missings. Because everything works perfectly well only when executed on an event listener like button touch, meanwhile I want the thing to appear or get executed with the scene ‘will’ event. Please help!!!
Greetings to members! First of all thanks to any member who was willing to assist me on the issue. Fortunately for me, i have manage to solve the problem my self, by modifying my caller function. Thanks once again.
Hi.
Before answering, let me ask you do the following:
- Please do not use ALL CAPS in titles. This is the electronic equivalent of shouting and some find it very off-putting.
- Please use paragraphs and other elements to make your future posts legible. One big mind-dump it semi-impenetrable and folks will not bother to read or answer it.
- While we appreciate your struggle and background, please just ask the question or at least separate out the salient bits, so we can get right to answering/helping.
Now, digging through the question… so it sounds like you’re having trouble with a touch handler and executing code in the show() method of a composer scene?
Please post the touch handler code and the code in your show() method, use code blocks, and take time to format for legibility without altering the code from what you’ve got.
Ex:
local function onTouch( event ) if( event.phase == "began" ) then end return false end
function scene:show( event ) local sceneGroup = self.view local willDid = event.phase if( willDid == "will" ) then elseif( willDid == "did" ) then end end
@ roaminggamer
First of all thanks for the directives and suggestions. I duly appreciate that. Thanks so much.
Now please, here is what I have for my touch handler code and the code on my OnShow event:
function page:show( event )
local pageComponent = self.view
local phase = event.phase
if ( phase == “will” ) then
local function handleMyTree(e)
if e.phase == “ended” then
myTree.onTreeButPress(appTreeData, {trObjArrayName = “Item 1”,
showLinks = true,
xPos = 100,
yPos = 100,
width = 25,
height = 12,
bounds = false,
OptColor = {0.98, 0.88, 0.98}
})
end
return true
end
tmrtreeshow = timer.performWithDelay( 500, handleMyTree, 1 )
Runtime:addEventListener( “touch”, handleMyTree )
elseif ( phase == “did” ) then
end
end
And the problem is I want the function to trigger automatically, before the scene shows, but neither the runtime listener nor the timer is able to trigger the function to work.
Thanks once again!
Oh please! No one will help me!
I am getting confused. I just don’t know why the script in the module gets compiled and run on a button event listener (I mean when I touch the button, everything works fine without any issues), but doesn’t work when i try calling the module function directly on a scene ‘will’ event, and doesn’t attach it to any listener. My code is too many, I would have posted it here!
Forgive me for my English expressions if I don’t sound clearly.
Please, I beg all members, sombody should just suggest possible missings. Because everything works perfectly well only when executed on an event listener like button touch, meanwhile I want the thing to appear or get executed with the scene ‘will’ event. Please help!!!
Greetings to members! First of all thanks to any member who was willing to assist me on the issue. Fortunately for me, i have manage to solve the problem my self, by modifying my caller function. Thanks once again.