2013-12-09 7 views
0

커스텀 애니메이션으로 롤링 주사위를 만들었습니다. Check out this video to see it애니메이션 코로나 로딩 중에 이전 이미지 삭제

이제 주사위 애니메이션이 시작되는 동안 이전 이미지가 배경에 머무르고 애니메이션이 끝난 후에 바뀝니다. 애니메이션이 시작될 때 배경에서 이미지를 제거하고 싶습니다. 아무도 내가 어떻게 할 수 있다고 말할 수 있습니까?

여기 내 주요 이벤트 코드

local function listener(event) 
if event.phase == "began" then 
    audio.play(diceSound) 
    dice = display.newImage("images/dice3droll.png") 
    physics.addBody(dice, {bounce = 2.8}) 
    physics.addBody(grass, "static", {bounce = 0.6}) 
    dice.x = display.contentWidth/2 
    dice.y = display.contentHeight/2 
    dice.isFocus = true 
    dice:scale(2,2) 
    display.getCurrentStage():setFocus(dice) 
    Runtime:addEventListener("enterFrame", rotateDice) 
    local function timerE(ev) 
     rand=math.random(6) 
     dice:removeSelf() 
     dice.isFocus = false 
     dice = display.newImage("images/dice"..rand..".png") 
     dice.x = display.contentWidth/2 
     dice.y = display.contentHeight/2 
     Runtime:removeEventListener("enterFrame", rotateDice) 
    end 

    timer.performWithDelay(2000, timerE, 1) 

end 
return true 
end 

답변

0

당신은 원본 이미지의 코드를 게시하지 못했지만, 나는 그것이 주사위라고 믿고있어. 이벤트가 시작되면 display.removeSelf(dice)으로 전화하십시오. global이 아닌 local 이래로 코드에서 변수를 섞을 수 있기 때문에 주사위 이외의 다른 애니메이션으로 이름을 바꾸는 것이 좋습니다.

관련 문제