how to change sprite sheets

I can load an image in a class and this works fine (dont like keep using self).

This is a right walking image and what do I if I change the walking movement so that it moves left? The left and right walking images are different.What method do I use in corona to swap the sprite movement on the same animation so it walks in the left and right direction?

do I load another set of images and only display 1 sprite set ?
local sprite = require( “sprite” )
local pteroSheet = sprite.newSpriteSheet( “monk3.png”, 32, 48 )
local pteroSet = sprite.newSpriteSet( pteroSheet, 1, 5 )
sprite.add( pteroSet, “ptero”, 1, 5, 300, -2 )
self.ptero = sprite.newSprite( pteroSet )
self.ptero:setReferencePoint( display.CenterReferencePoint )
self.ptero.x = display.contentWidth / 2
self.ptero.y = display.contentHeight / 2
self.ptero:prepare( “ptero” )
self.ptero:play() [import]uid: 138547 topic_id: 25109 reply_id: 325109[/import]

I cant get the 2 sprite sheets to change over to make it look like the char is walking left then right.
I just need to swap over 2 sprite animations in 1 spot

[lua] local sprite = require( “sprite” )
local pteroSheet = sprite.newSpriteSheet( “monk3.png”, 32, 48 )
local pteroSet = sprite.newSpriteSet( pteroSheet, 1, 5 )
sprite.add( pteroSet, “monk1”, 1, 5, 300, -2 )
self.monk1 = sprite.newSprite( pteroSet )
– self.monk1:setReferencePoint( display.CenterReferencePoint )
self.monk1:prepare( “monk1” )
self.monk1:play()

local pteroSheet2 = sprite.newSpriteSheet( “monk4.png”, 32, 48 )
local pteroSet2 = sprite.newSpriteSet( pteroSheet2, 1, 5 )
sprite.add( pteroSet2, “monk2”, 1, 5, 300, -2 )
self.monk2 = sprite.newSprite( pteroSet2 )
self.monk2:prepare( “monk2” )
self.monk2:play()

self.walkDirection=“right”
mgroup = display.newGroup();
mgroup:insert( self.monk1 );
mgroup.x=100;
mgroup.y=150;

end
function player:moveleft()
if self.walkDirection==“right” then
mgroup:remove(1);
mgroup=nil;
mgroup = display.newGroup();
mgroup:insert( self.monk2 );
self.walkDirection=“left”;
end
mgroup.x=mgroup.x-10;

end

function player:moveright()
if self.walkDirection==“left” then
mgroup:remove(1);
mgroup=nil;
mgroup:insert( self.monk1 );
self.walkDirection=“right”;
end

mgroup.x=mgroup.x+10;

end[/lua] [import]uid: 138547 topic_id: 25109 reply_id: 102001[/import]

This tutorial shows how to walk a sprite in 4 directions (up, down, left and right) and change animations accordingly; http://techority.com/2011/05/01/using-sprites-in-your-corona-iphone-application/

I believe that will help you :slight_smile: [import]uid: 52491 topic_id: 25109 reply_id: 102010[/import]

yes I found this before and I understand this now.

So I dont need to put everything in groups as well?

How do I avoid loading these sprites behind background images? [import]uid: 138547 topic_id: 25109 reply_id: 102026[/import]

Just load the background before the sprite.

–Add background here

–Add sprite here

Sprite would then be in front.

If you want to load the background after the sprite for some reason simply use background:toBack() after you have loaded the sprite.

You can use groups if you wish but no, it isn’t needed. [import]uid: 52491 topic_id: 25109 reply_id: 102093[/import]