Hi Brent,
Here’s the relevant code - I realise I’m not using composer well. As you mention, it’s likely to be the jump function itself?
[lua]
display.setStatusBar(display.HiddenStatusBar)
local composer = require( “composer” )
local scene = composer.newScene()
local physics = require( “physics” )
system.activate( “multitouch” )
physics.start()
physics.setGravity( 0, 9.8 )
physics.pause()
local dusk = require(“Dusk.Dusk”)
local textureFilter = “nearest”
display.setDefault(“magTextureFilter”, textureFilter)
– forward declarations and other locals
local arthur
local arthurData
local jumped = audio.loadSound ( “audio/jump.wav” )
local jumpbutton
function scene:create( event )
local sceneGroup = self.view
local gui = display.newGroup()
local guifront = display.newGroup()
gui:insert(guiback)
gui:insert(guifront)
map = dusk.buildMap(“levelgraphic2.json”)
map:scale (1, 1)
map.setTrackingLevel(0.9)
guiback:insert(map)
map.setCameraBounds ({ xMin = display.contentCenterX, yMin = display.contentCenterY, xMax = map.data.width - display.contentCenterX, yMax = map.data.height - display.contentCenterY })
map.layer[1].setCameraOffset(14, 24)
map.layer[2].setCameraOffset(14, 24)
map.updateView ()
-----------------------------------------------------------------------------Player
sheet1 = graphics.newImageSheet( “arthur.png”, { width=25, height=37, numFrames=14 } )
arthurData =
{
{ name=“standing”, frames= { 13 } },
{ name=“running”, start=1, count=12, time=framerate },
{ name=“beenhit”, frames= { 14 } }
}
arthur = display.newSprite( sheet1, arthurData )
arthur.x = 140
arthur.y = 106
arthur.id = “arthur”
arthur.title = “arthur”
arthur.myName = “arthur”
arthur.rotation = 0
arthur.anchorY = 1
arthur.anchorX = 0.5
arthur:setSequence(“standing”)
arthur:play()
physics.addBody( arthur, “dynamic”, { density=1, friction=0.5, bounce=0} )
arthur.isFixedRotation = true
map.layer[1]:insert(arthur)
------------------------------------------------------------------------------------- jump button
jumpbutton = display.newRect( display.contentWidth+((display.actualContentWidth-display.contentWidth)/2), display.contentHeight-50, screenW/8, 50 )
jumpbutton.anchorX = 1
jumpbutton.anchorY = 0
jumpbutton:setFillColor( 1, 0, 1 )
jumpbutton.id = “jumpbutton”
guifront:insert(jumpbutton)
------------------------------------------------------------------------------------------jumping function
local function onJumpButtonRelease ( event )
if event.phase == “began” and arthur.y >105 then
print( “jumped” )
audio.play ( jumped )
arthur:applyLinearImpulse( 0, -2, arthur.x, arthur.y )
canJump = 0
return true
end
end
end
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if phase == “will” then
physics.start()
elseif phase == “did” then
end
end
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
if event.phase == “will” then
elseif phase == “did” then
end
end
function scene:destroy( event )
local sceneGroup = self.view
transition.cancel()
physics.pause()
physics.removeBody( arthur )
jumpbutton:removeEventListener( “touch”, onJumpButtonRelease )
display.remove(map)
map = nil
arthur:removeSelf()
arthur = nil
jumpbutton:removeSelf()
jumpbutton = nil
end
– Listener setup
scene:addEventListener( “create”, scene )
scene:addEventListener( “show”, scene )
scene:addEventListener( “hide”, scene )
scene:addEventListener( “destroy”, scene )
return scene
[/lua]
Many thanks.