0

我是使用电晕创建 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)

任何想法将不胜感激。

4

1 回答 1

0

你试过 .remove(person) 吗?

于 2013-05-12T16:30:33.587 回答