changing storyboard scene

Hello,

Does anyone know if is it possible to change a scene by pressing an android hardware key ??

thanks [import]uid: 185094 topic_id: 33699 reply_id: 333699[/import]

Yes, it is possible… I have that working in an app I released earlier this year.

create a Runtime listener:

Runtime:addEventListener("key", onAndroidKeyPress)  

then in the AndroidkeyPress function, check to see if the key press == “back”

function onAndroidKeyPress(event)  
 if event.keyName == "back" and event.phase == "up" then  
 isBackButtonPressed = true  
 -- move to a new scene here  
 end  
 return true  
end  

I beleive you can also check for event.keyName == "menu", but I haven’t tried it. [import]uid: 114363 topic_id: 33699 reply_id: 134038[/import]

can you tell me where to put these codes?? what i mean is do i have to put them on createscene function? [import]uid: 185094 topic_id: 33699 reply_id: 134131[/import]

Yes, it is possible… I have that working in an app I released earlier this year.

create a Runtime listener:

Runtime:addEventListener("key", onAndroidKeyPress)  

then in the AndroidkeyPress function, check to see if the key press == “back”

function onAndroidKeyPress(event)  
 if event.keyName == "back" and event.phase == "up" then  
 isBackButtonPressed = true  
 -- move to a new scene here  
 end  
 return true  
end  

I beleive you can also check for event.keyName == "menu", but I haven’t tried it. [import]uid: 114363 topic_id: 33699 reply_id: 134038[/import]

can you tell me where to put these codes?? what i mean is do i have to put them on createscene function? [import]uid: 185094 topic_id: 33699 reply_id: 134131[/import]