Hey guys,
I can’t find how to swap an image to a different one from the sprite sheet.
I have an object “gem” with ‘gem.MyGemID’ attribute
And I set up a sprite sheet like this:
[lua]
local gemSheetOptions = {
width = 80,
height = 80,
numFrames = 6,
}
local gemSheet = graphics.newImageSheet ( “images/gemSheet.png” ,gemSheetOptions )
[/lua]
Now I have the gem setup like this:
[lua]
local gem = display.newImage( gemSheet, 1 ) – starting image is 1
gem.width = 40
gem.height = 40
gem.x = 20
gem.y = 424
gem.MyRow = (gem.y - firstRowY + gemDimentions)/gemDimentions
gem.MyCol = (gem.x - firstColX + gemDimentions)/gemDimentions
gem.MyGemID = board[gem.MyRow][gem.MyCol]
– Now i would like to change its image based on its gem.MyGemID from the sheet
[/lua]
And I want to swap its image from the sprite sheet according to its “gem.MyGemID” variable…
And I cant seem to find how to do this.
Im a total newbie so go easy on me
Any help will be greatly appreciated
Roy.