Hiding the Previous Sprite Sheet

I’m new in corona and I’m trying to create a character that move’s using the codes below. My problem is it leaves the sprite mark when moving. How can I hide or erase the previous sprite mark?

-----------My Codes---------------

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)

Hi Kevin,

This doesn’t answer your direct question, but I see that you’re using the old, deprecated “sprite.” library. This was replaced some time ago by a sprite system tied into the “display.” library. I suggest before you do anything else, you convert to this current method, as the old library will get no official support.

Here is a tutorial on the current methods. I think you’ll find it easy to convert and easier to use.

http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

Best regards,

Brent Sorrentino

Sir but how can I hide the previous sprite. I’m trying to move up, down, left, right the display using applyForce but it leave sprite mark. The link that you gave is not moving forward or etc. Thanks.

Hi @kevinmadredia,

You’ve got the right idea, basically, but you’re creating a new sprite every single “cycle” of the game. If you want just one character, you should create it, add the physics body, and apply the force just once. You won’t need the Runtime listener in that case… the force will be applied, and the object will continue to move up under the influence of that force.

Regards,

Brent

I just used the Runtime listener so the character will move continuously while the player is holding the control button . By the thanks for the info. I already changed the method that I use basing to that tutorial you gave. 

Hi Kevin,

This doesn’t answer your direct question, but I see that you’re using the old, deprecated “sprite.” library. This was replaced some time ago by a sprite system tied into the “display.” library. I suggest before you do anything else, you convert to this current method, as the old library will get no official support.

Here is a tutorial on the current methods. I think you’ll find it easy to convert and easier to use.

http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

Best regards,

Brent Sorrentino

Sir but how can I hide the previous sprite. I’m trying to move up, down, left, right the display using applyForce but it leave sprite mark. The link that you gave is not moving forward or etc. Thanks.

Hi @kevinmadredia,

You’ve got the right idea, basically, but you’re creating a new sprite every single “cycle” of the game. If you want just one character, you should create it, add the physics body, and apply the force just once. You won’t need the Runtime listener in that case… the force will be applied, and the object will continue to move up under the influence of that force.

Regards,

Brent

I just used the Runtime listener so the character will move continuously while the player is holding the control button . By the thanks for the info. I already changed the method that I use basing to that tutorial you gave.