У меня есть приложение, которое продолжает замерзать на 9-й сцене. В настоящее время я использую раскадровку, и идея состоит в том, чтобы перейти на сцену, когда игроки ответили на вопрос. Я использовал операторы печати, чтобы подтвердить, что корона вошла в десятую сцену (все коды работают и запускаются в сцене10), но симулятор замерзает на сцене 9. Я попытался связать сцену 9 с сценой 1, которая также является тем же результатом, симулятор экран зависает на сцене9 вместо перехода на сцену1, но операторы печати в сцене 1 показаны на симуляторе. Коды работают, поскольку у меня есть инструкции печати в каждой функции. Я вынул некоторые коды и изменил имя файлов, но не повезло. На что еще я могу смотреть?Код работает отлично, но симулятор короны замерзает в конкретной сцене
Я побежал код на мой телефон и получил некоторые, что, кажется, некоторые ошибки:
D/CrashAnrDetector(2962): Hardware: universal5410
D/CrashAnrDetector(2962): Revision: 10
D/CrashAnrDetector(2962): Bootloader: I9500ZSUCMK3
D/CrashAnrDetector(2962): Radio: unknown
D/CrashAnrDetector(2962): Kernel: Linux version 3.4.5-2138764 ([email protected]
8) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #1 SMP PREEMPT Fri No
v 15 16:58:07 KST 2013
, а затем несколько детекторов аварии с кучей цифр, стоящих за ним.
D/CrashAnrDetector(2962): d0 65746172656e6567 d1 7571207478656e20
D/CrashAnrDetector(2962): d2 0000000000000000 d3 0000000000000000
D/CrashAnrDetector(2962): d4 0000000000000000 d5 3ff0000000000000
D/CrashAnrDetector(2962): d6 c00ffffe00000000 d7 c07ffff000000000
D/CrashAnrDetector(2962): d8 40400030c07ffff0 d9 000000003f800000
D/CrashAnrDetector(2962): d10 000000003f7fffec d11 0000000000000000
.....
E/android.os.Debug(2962): [email protected] > dumpstate -k -t -z -d -o /data/log/dump
state_app_error
I/dumpstate(29372): begin
I/dumpstate(29372): dumpstate is still running
....
Что я мог бы сделать из этого является то, что приложение разбился, и там, кажется, что-то неправильно с проблемой хранения? (Я думаю, вот что dumpstate относится к?)
local storyboard = require("storyboard")
local widget = require "widget"
local scene = storyboard.newScene()
local function returnHome()
storyboard.gotoScene("scene_menu", "crossFade",1000)
return true
end
local physics = require('physics')
physics.start()
-- Clear previous scene
-- local forward references should go here --
local score = 0
local scoreText
local scoreForLevelComplete
local background
local infoBar
local restartBtn
local cannon
local levelNum
local balloon = {}
local cannonCharge = {}
local ballCollision = {}
local shot = {}
local cannonBall
local impulse = 0
local balloons = {}
local cannonCharge = {}
local shot = {}
local cannonBalls = display.newGroup()
local pop = audio.loadSound('pop.mp3')
local wrongAnswer
---------------------------------------------------------------------------------
-- BEGINNING OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------
function scene:createScene(event)
local group = self.view
storyboard.removeAll()
print('purge scene')
end
function scene:enterScene(event)
local group = self.view
background = display.newImage("bkg_clouds.png")
group:insert(background)
background.x = 230
background.y = 195
scoreText = display.newText(storyboard.state.score, 0, 0, native.systemFont, 32)
scoreText:setFillColor(0,0, 0)
scoreText.x = 87
scoreText.y = 28
group:insert(scoreText)
questionText = display.newText('a', display.contentCenterX, display.contentWidth/4, native.systemFont, 40)
group:insert(questionText)
infoBar = display.newImage ("infoBar.png")
group:insert(infoBar)
infoBar.x = 10
infoBar.y = 25
restartBtn = widget.newButton{
defaultFile = "restartBtn.png",
onRelease = returnHome
}
restartBtn.x = 470
restartBtn.y = 300
group:insert(restartBtn)
cannon = display.newImage ("cannon.png")
group:insert(cannon)
cannon.x = 10
cannon.y = 270
cannon.anchorX = 0.5
cannon.anchorY = 0.5
restartBtn.isVisible = true
local MemoryLabel = display.newText(
{
text = '',
x = 250,
y = 220,
font = 'Arial',
fontSize = 32,
align = "center"
}
)
MemoryLabel:setFillColor(0)
group:insert(MemoryLabel)
local TextureLabel = display.newText(
{
text = '',
x = 250,
y = 200,
font = 'Arial',
fontSize = 32,
align = "center"
}
)
TextureLabel:setFillColor(0)
group:insert(TextureLabel)
-- To check available memory
function checkMemory()
collectgarbage("collect")
MemoryLabel.text = string.format("M:%.2f KB", collectgarbage("count"))
TextureLabel.text = "T:"..(string.format("%.2f KB", system.getInfo("textureMemoryUsed")/(1024 * 1024)))
end
timer.performWithDelay(1000, checkMemory, 0)
local balloon1 = display.newImage ('balloon_fat_red.png', 495, 70)
local balloon2 = display.newImage ('balloon_fat_red.png', 495, 115)
local balloon3 = display.newImage ('balloon_fat_red.png', 495, 160)
group:insert(balloon1)
group:insert(balloon2)
group:insert(balloon3)
physics.addBody(balloon1)
physics.addBody(balloon2)
physics.addBody(balloon3)
balloon1.bodyType = 'static'
balloon2.bodyType = 'static'
balloon3.bodyType = 'static'
table.insert(balloons, balloon1)
table.insert(balloons, balloon2)
table.insert(balloons, balloon3)
local balloonText1 = display.newText('\227\129\130', 495, 70)
balloonText1:setFillColor(1,1, 0)
local balloonText2 = display.newText('\227\129\132', 495, 115)
balloonText2:setFillColor(1,1, 0)
local balloonText3 = display.newText('\227\129\134', 495, 160)
balloonText3:setFillColor(1,1, 0)
group:insert(balloonText1)
group:insert(balloonText2)
group:insert(balloonText3)
function cannonCharge:touch(event)
if(event.phase == 'began') then
impulse = 0
cannon.isVisible = true
Runtime:addEventListener('enterFrame', charge)
print ('cannonCharge')
end
end
function shot:touch(event)
if(event.phase == 'ended') then
Runtime:removeEventListener('enterFrame', charge)
cannon.isVisible = true
cannon.rotation = 0
cannonBall = display.newImage('cannon ball.png', 84, 220)
physics.addBody(cannonBall, {density = 1, friction = 0, bounce = 0})
group:insert(cannonBall)
print ('shot')
-- Shoot cannon ball
cannonBall:applyLinearImpulse(3, impulse, cannonBall.x, cannonBall.y)
--Collision listener
print('event listener')
cannonBall:addEventListener ('collision', ballCollision)
end
end
function charge()
local degreesPerFrame = 1
cannon.rotation = cannon.rotation - degreesPerFrame
impulse=impulse-0.2
if(cannon.rotation < -46) then
cannon.rotation = -46
impulse = -3.2
print('Charge')
end
end
function ballCollision(event)
if (event.other == balloons[1]) then
scene.updateScore()
print('Ball is colliding')
balloon1:removeSelf()
balloon1 = nil
balloonText1:removeSelf()
balloonText1 = nil
local popSound = audio.play(pop)
print('Before changing scene')
storyboard.gotoScene("correct1", "fade", 3000)
else
if (event.other == balloons[2]) then
print('Ball is colliding')
balloon2:removeSelf()
balloon2 = nil
balloonText2:removeSelf()
balloonText2 = nil
local popSound = audio.play(pop)
print('Before changing scene')
storyboard.gotoScene("wrong1", "fade", 3000)
else
if (event.other == balloons[3]) then
print('Ball is colliding')
balloon3:removeSelf()
balloon3 = nil
balloonText3:removeSelf()
balloonText3 = nil
local popSound = audio.play(pop)
print('Before changing scene')
storyboard.gotoScene("wrong1", "fade", 3000)
end
end
end
end
background:addEventListener('touch', cannonCharge)
background:addEventListener('touch', shot)
end
function scene.updateScore()
storyboard.state.score = storyboard.state.score + 50
scoreText.text = storyboard.state.score
end
-- Called when the scene's view does not exist:
function scene:exitScene(event)
local group = self.view
background:removeEventListener('touch', cannonCharge)
background:removeEventListener('touch', shot)
end
function scene:destroyScene(event)
audio.stop(popSound)
audio.dispose(pop)
popSound = nil
pop = nil
--cannonBall:removeEventListener ('collision', ballCollision)
if restartBtn then
restartBtn:removeSelf()
restartBtn = nil
end
end
scene:addEventListener("createScene", scene)
scene:addEventListener("updateScore", scene)
scene:addEventListener("enterScene", scene)
scene:addEventListener("exitScene", scene)
scene:addEventListener("destroyScene", scene)
return scene
Так что это переходит к следующей сцене:
local storyboard = require("storyboard")
local widget = require "widget"
local scene = storyboard.newScene()
local function returnHome()
storyboard.gotoScene("scene_menu", "crossFade",1000)
return true
end
local physics = require('physics')
physics.start()
-- Clear previous scene
storyboard.removeAll()
-- local forward references should go here --
local scoreText
local background
local infoBar
local restartBtn
local cannon
local balloon = {}
local cannonCharge = {}
local ballCollision = {}
local shot = {}
local cannonBall
local impulse = 0
local balloons = {}
local cannonCharge = {}
local shot = {}
local cannonBalls = display.newGroup()
local pop = audio.loadSound('pop.mp3')
local wrongAnswer
---------------------------------------------------------------------------------
-- BEGINNING OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------
function scene:createScene(event)
local group = self.view
storyboard.removeAll()
print('purge scene')
end
function scene:enterScene(event)
local group = self.view
background = display.newImage("bkg_clouds.png")
group:insert(background)
background.x = 230
background.y = 195
local cannon = display.newImage ("cannon.png")
group:insert(cannon)
cannon.x = 10
cannon.y = 270
scoreText = display.newText(storyboard.state.score, 0, 0, native.systemFont, 32)
scoreText:setFillColor(0,0, 0)
scoreText.x = 87
scoreText.y = 28
group:insert(scoreText)
questionText = display.newText('i', display.contentCenterX, display.contentWidth/4, native.systemFont, 40)
group:insert(questionText)
infoBar = display.newImage ("infoBar.png")
group:insert(infoBar)
infoBar.x = 10
infoBar.y = 25
restartBtn = widget.newButton{
defaultFile = "restartBtn.png",
onRelease = returnHome
}
restartBtn.x = 470
restartBtn.y = 300
group:insert(restartBtn)
cannon = display.newImage ("cannon.png")
group:insert(cannon)
cannon.x = 10
cannon.y = 270
cannon.anchorX = 0.5
cannon.anchorY = 0.5
restartBtn.isVisible = true
local MemoryLabel = display.newText(
{
text = '',
x = 250,
y = 220,
font = 'Arial',
fontSize = 32,
align = "center"
}
)
MemoryLabel:setFillColor(0)
group:insert(MemoryLabel)
local TextureLabel = display.newText(
{
text = '',
x = 250,
y = 200,
font = 'Arial',
fontSize = 32,
align = "center"
}
)
TextureLabel:setFillColor(0)
group:insert(TextureLabel)
-- To check available memory
function checkMemory()
collectgarbage("collect")
MemoryLabel.text = string.format("M:%.2f KB", collectgarbage("count"))
TextureLabel.text = "T:"..(string.format("%.2f KB", system.getInfo("textureMemoryUsed")/(1024 * 1024)))
end
timer.performWithDelay(1000, checkMemory, 0)
local balloon1 = display.newImage ('balloon_fat_red.png', 495, 70)
local balloon2 = display.newImage ('balloon_fat_red.png', 495, 115)
local balloon3 = display.newImage ('balloon_fat_red.png', 495, 160)
group:insert(balloon1)
group:insert(balloon2)
group:insert(balloon3)
physics.addBody(balloon1)
physics.addBody(balloon2)
physics.addBody(balloon3)
balloon1.bodyType = 'static'
balloon2.bodyType = 'static'
balloon3.bodyType = 'static'
table.insert(balloons, balloon1)
table.insert(balloons, balloon2)
table.insert(balloons, balloon3)
local balloonText1 = display.newText('\227\129\141', 495, 70)
balloonText1:setFillColor(1,1, 0)
local balloonText2 = display.newText('\227\129\138', 495, 115)
balloonText2:setFillColor(1,1, 0)
local balloonText3 = display.newText('\227\129\132', 495, 160)
balloonText3:setFillColor(1,1, 0)
group:insert(balloonText1)
group:insert(balloonText2)
group:insert(balloonText3)
function cannonCharge:touch(event)
if(event.phase == 'began') then
impulse = 0
cannon.isVisible = true
Runtime:addEventListener('enterFrame', charge)
print ('cannonCharge')
end
end
function shot:touch(event)
if(event.phase == 'ended') then
Runtime:removeEventListener('enterFrame', charge)
cannon.isVisible = true
cannon.rotation = 0
cannonBall = display.newImage('cannon ball.png', 84, 220)
physics.addBody(cannonBall, {density = 1, friction = 0, bounce = 0})
group:insert(cannonBall)
print ('shot')
-- Shoot cannon ball
cannonBall:applyLinearImpulse(3, impulse, cannonBall.x, cannonBall.y)
--Collision listener
print('event listener')
cannonBall:addEventListener ('collision', ballCollision)
end
end
function charge()
local degreesPerFrame = 1
cannon.rotation = cannon.rotation - degreesPerFrame
impulse=impulse-0.2
if(cannon.rotation < -46) then
cannon.rotation = -46
impulse = -3.2
print('Charge')
end
end
function ballCollision(event)
if (event.other == balloons[1]) then
print('Ball is colliding')
balloon1:removeSelf()
balloon1 = nil
balloon2:removeSelf()
balloon2 = nil
balloon3:removeSelf()
balloon3 = nil
balloonText1:removeSelf()
balloonText1 = nil
balloonText2:removeSelf()
balloonText2 = nil
balloonText3:removeSelf()
balloonText3 = nil
local popSound = audio.play(pop)
storyboard.gotoScene("Question3", "fade", 1000)
else
if (event.other == balloons[2]) then
print('Ball is colliding')
balloon1:removeSelf()
balloon1 = nil
balloon2:removeSelf()
balloon2 = nil
balloon3:removeSelf()
balloon3 = nil
balloonText1:removeSelf()
balloonText1 = nil
balloonText2:removeSelf()
balloonText2 = nil
balloonText3:removeSelf()
balloonText3 = nil
local popSound = audio.play(pop)
storyboard.gotoScene("Question3", "fade", 1000)
else
if (event.other == balloons[3]) then
scene.updateScore()
print('Ball is colliding')
balloon1:removeSelf()
balloon1 = nil
balloon2:removeSelf()
balloon2 = nil
balloon3:removeSelf()
balloon3 = nil
balloonText1:removeSelf()
balloonText1 = nil
balloonText2:removeSelf()
balloonText2 = nil
balloonText3:removeSelf()
balloonText3 = nil
local popSound = audio.play(pop)
storyboard.gotoScene("Question3", "fade", 1000)
end
end
end
end
background:addEventListener('touch', cannonCharge)
background:addEventListener('touch', shot)
end
function scene.updateScore()
storyboard.state.score = storyboard.state.score + 50
scoreText.text = storyboard.state.score
end
-- Called when the scene's view does not exist:
function scene:exitScene(event)
local group = self.view
cannonBall:removeSelf()
cannonBall = nill
audio.stop(popSound)
audio.dispose(pop)
popSound = nil
pop = nil
background:removeEventListener('touch', cannonCharge)
background:removeEventListener('touch', shot)
physics.stop()
end
function scene:destroyScene(event)
if restartBtn then
restartBtn:removeSelf()
restartBtn = nil
end
end
scene:addEventListener("createScene", scene)
scene:addEventListener("updateScore", scene)
scene:addEventListener("enterScene", scene)
scene:addEventListener("exitScene", scene)
scene:addEventListener("destroyScene", scene)
return scene
Вы удаляете все объекты, созданные внутри сцены 9 ..? –
Да, у меня есть storyboard.removeAll() в начале createScene для каждого файла кода, который, я думаю, удаляет объекты, модули и т. Д. – user3305142
Это может быть несколько причин. Если вы настроите свое приложение так, чтобы оно переходило от основного к сцене 10 к сцене 9 в сцену 1 (никаких других сцен между ними), он все еще замирает? – Schollii