I’m using the storyboard, and when Im in the enterScene part to call functions it is not calling.
The function is at line 81(level1Presents()). I thought it would call itself, and I tried calling it elsewhere. to no avail… The program will run right up to that point and print ‘1:enterScene event’
[lua]----------------------------------------------------------------------------------
– scenetemplate.lua
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local p = 0
local bg1, floor1, santa, triangleShape, lever, present1, present2, present3, dropButton
local phys1 = {friction = .7, bounce = .1, density = .3}
local h = display.contentHeight
local w = display.contentWidth
physics = require(‘physics’)
physics.start()
physics.setGravity(0,9.3)–gravity 3-5 good
–physics.setDrawMode(‘hybrid’)
–
– NOTE:
– Code outside of listener functions (below) will only be executed once,
– unless storyboard.removeScene() is called.
– BEGINNING OF YOUR IMPLEMENTATION
– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view
bg1 = display.newImage(‘bg1.jpg.’)
group:insert(bg1)
floor1 = display.newRect(0, h-1, w, 1)
floor1.name = ‘floor1’
physics.addBody(floor1, “static”,{density = 9, friction = .7, bounce = .2})
–floor1:addEventListener(‘collision’, onCollision)
group:insert(floor1)
santa = display.newImageRect(‘santa.jpg’, 100, 100)
santa.x = w/2
santa.y = h-40
triangleShape = { 0,-50, 50,50, -50,50 }
physics.addBody( santa, {density=9, friction=0.5, bounce=0, shape=triangleShape } )
group:insert(santa, triangleShape)
lever = display.newRect(w/2-350, h-125, 700, 30)
lever:setFillColor(0, 230, 29)
lever.name = ‘lever’
physics.addBody(lever,‘dynamic’, {density = 3, friction = .7, bounce = 0})
myJoint = physics.newJoint(‘pivot’, santa, lever, w/2, h-140)
group:insert(lever, myJoint)
– CREATE display objects and add them to ‘group’ here.
– Example use-case: Restore ‘group’ from previously saved state.
end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
–local group = self.view
print( “1: enterScene event” )
–level1Presents()
local function level1Presents()
p = p+1
print §
if (p ==1) then
present1 = display.newImageRect(‘present1.jpg’, 50, 50)
physics.addBody(present1, ‘kinematic’, phys1)
present1.x = w/2
present1.y = h/7
present1:addEventListener(‘touch’, onTouch)
elseif (p == 2) then
present2 = display.newImageRect(‘present2.gif’,50, 50)
physics.addBody(present2, ‘kinematic’, phys1)
present2.x = w/2
present2.y = h/6
present2:addEventListener(‘touch’, onTouch)
elseif (p == 3) then
present3 = display.newImageRect(‘present3.gif’, 50, 50)
physics.addBody(present3, ‘kinematic’, phys1)
present3.x = w/2
present3.y = h/6
present3.rotation = 5
present3:addEventListener(‘touch’, onTouch)
end
end
end [import]uid: 75779 topic_id: 19583 reply_id: 319583[/import]