隐藏上一个精灵

时间:2013-05-08 06:44:41

标签: android corona

我是使用电晕创建Android游戏的新手,我正在尝试使用下面的代码创建一个移动的角色。我的问题是它在移动时留下了精灵标记。如何隐藏或删除上一个精灵标记?

local start = display.newImage( "start.png" )
physics.addBody(start, {friction = 1.0, density = 1.0})
start.bodyType = "static"
start.x = field.contentWidth/2 - 40
start.y = field.contentHeight/2
start.isFixedRotation = "true"

function spriteup()
    personSpriteSheet = sprite.newSpriteSheet("back.png", 30, 45)
    personSprite = sprite.newSpriteSet(personSpriteSheet, 1, 4)
    sprite.add(personSprite, "test", a, a, 1000, 1)
    person = sprite.newSprite(personSprite)
    person.x = start.x + 2
    person.y = start.y
    person:prepare("test")

end

function moveup(self, event)
    self:applyForce(0, -15, event.x, event.y)
    spriteup()
    if a == 4 then
        a = 0
    end
    a =a + 1
end 

local function listenerup(event)
    if event.phase == "began" then
    start.bodyType = "dynamic"
    start.alpha = 0
    if a == 4 then
        a = 0
    end
    a = a + 1
    start.enterFrame = moveup
    Runtime:addEventListener("enterFrame", start)
    else
        Runtime:removeEventListener("enterFrame", start)
        start.bodyType = "static"
    end
    return true
end
up:addEventListener( "touch", listenerup)

任何想法都将受到高度赞赏。

1 个答案:

答案 0 :(得分:0)

你有没有尝试过.remove(人)?