[lua]---------------------------------------------------------------------------------
– scene9.lua
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
– BEGINNING OF YOUR IMPLEMENTATION
local background
local function myimage2( self, event )
if event.phase == “began” then
x=x-1
textObject.text = x
return true
end
end
– Called when the scene’s view does not exist:
function scene:createScene( event )
local screenGroup = self.view
background = display.newImage( “background.png” )
screenGroup:insert( background )
myimage = display.newImage(“myimage.png”)
myimage.x = display.contentWidth / 5
myimage.y = display.contentHeight / 2
screenGroup:insert( myimage )
myimage.touch = myimage2
level1_apple:addEventListener( “touch”, apple )
print( “\n9: createScene event”)
x=5
local textObject = display.newText( x, 4, -1, “GoodDog Plain”, 20 )
textObject:setTextColor( 255,255,255 )
screenGroup:insert( textObject )
end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
storyboard.printMemUsage()
print( “9: enterScene event” )
end
– Called when scene is about to move offscreen:
function scene:exitScene( event )
print( “9: exitScene event” )
end
– Called prior to the removal of scene’s “view” (display group)
function scene:destroyScene( event )
print( “((destroying scene 9’s view))” )
end
– END OF YOUR IMPLEMENTATION
– “createScene” event is dispatched if scene’s view does not exist
scene:addEventListener( “createScene”, scene )
– “enterScene” event is dispatched whenever scene transition has finished
scene:addEventListener( “enterScene”, scene )
– “exitScene” event is dispatched before next scene’s transition begins
scene:addEventListener( “exitScene”, scene )
– “destroyScene” event is dispatched before view is unloaded, which can be
– automatically unloaded in low memory situations, or explicitly via a call to
– storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( “destroyScene”, scene )
return scene
[/lua]
How can I update the x to 4, 3 ,2 ,1 when the image is clicked?
Currently, it remains 5 whatever I try to do…
Thanks for the help! [import]uid: 208318 topic_id: 37090 reply_id: 67090[/import]