Hello,
I am loading a sprite in the scene:create part and starting the animation in the scene:show did phase.
But the audio for the sprite and the sprite animation start while the screen is still black.
How can I fix this?
I don’t want to create a delay timer to delay it even longer. The load times differ per device.
[lua]
function scene:create( event )
local sceneGroup = self.view
local background=newImage(sceneGroup,“plaatjes/splashScreen.png”,1024,768)
PlaceImageCenter(background)
monster1HoofdSprite = display.newSprite( sceneGroup,monster1HoofdSheet,monster1SequenceData )
monster1HoofdSprite.x=myWidth*0.3
monster1HoofdSprite.y=myHeight*0.6
– Initialize the scene here.
– Example: add display objects to “sceneGroup”, add touch listeners, etc.
end
– “scene:show()”
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == “will” ) then
– Called when the scene is still off screen (but is about to come on screen).
elseif ( phase == “did” ) then
– Called when the scene is now on screen.
– Insert code here to make the scene come alive.
– Example: start timers, begin animation, play audio, etc.
local function NextScreen()
composer.gotoScene( “hoofdmenu-iPad”,{effect = “crossFade”,time=500} )
end
monster1HoofdSprite:setSequence(“dance”)
monster1HoofdSprite:play()
audio.play(monsterBrul)
timer.performWithDelay(2600,NextScreen)
end
end
[/lua]