Hello everyone,
I having a little issue with spritesheets. It maybe a very small tweak that’s needed, but I just cant seem to get it to work.
Here’s the issue:
I am playing around with a quick concept for a boggle game. I have a grid (4x4) that holds letters of the alphabet. These letters are being generated randomly from a spritesheet image. Here’s the code:
local options = { width = 70, height = 65, numFrames = 26 } local letterSheet = graphics.newImageSheet( "IMG/boggletiles.png", options ) local sequenceData = { { name = "letters", start=1, count=26, time=1000, loopCount=1 } }
And then I have the following for getting the letters into a grid (randomly), and mask which is used for when player taps the letter:
---LETTER TILES ---- local letterList = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"} local letter = {} local mask = {} local letterGroup = display.newGroup( ) group:insert(letterGroup) local maskGroup = display.newGroup( ) group:insert(maskGroup) --masks for x = 1, 4 do for y = 1, 4 do mask[#mask+1] = display.newImageRect( "IMG/mask.png", 70, 65 ) mask[#mask].x = x\*70-15 mask[#mask].y = y\*65+70 mask[#mask].isVisible = false maskGroup:insert(mask[#mask]) end end --setSequence( "c" ) --display.newSprite( letterSheet, sequenceData ) --LETTERS for x = 1, 4 do for y= 1, 4 do letter[#letter+1] = display.newSprite( letterSheet, sequenceData ) --sprite.newSprite(letterSet) letter[#letter].x = x\*70-15 letter[#letter].y = y\*65+70 letter[#letter].currentFrame = math.random(1,26) letter[#letter].val = letterList[letter[#letter].currentFrame] letter[#letter].state = "unspent" letter[#letter].mask = mask[#letter] letter[#letter]:addEventListener("tap", tapLetter) topBarGroup:insert( letter[#letter] ) end end topBarGroup:insert(letterGroup) topBarGroup:insert(maskGroup)
Everything works as intended - I get the correct mapping of each letter value etc… However,
all I see is letter “A” being displayed in every row and column, which means that the spriteSheet is only “sitting” on the first frame, and not going through all the 26 letters of the alphabet. Does this make sense?
What Am I doing wrong that’s preventing from the sprite to show all the frames?
I have attached an image so you can see what I am talking about.
Any help is highly appreciated.
Thanks