Hi,
Playing with the Game Edition sprite stuff-- lots of fun. However, if I want to have all my sprites on one sheet (not like the Jungle demo) to save on draw calls, and don’t actually want a sprite to animate, what’s the best way to do this? Currently, my attempts work great in the Simulator but on the device the “static” sprites I’m trying to make start with one image and then switch to another shortly after the app launches.
I’m using a 512x512 PNG with 64x64 tiles on it; nothing special. Here’s the code:
require("math")
require("sprite")
--require("entity")
local screenW = 1024
local screenH = 768
local tileW = 64
local tileH = 64
local scrTileW = screenW / tileW
local scrTileH = screenH / tileH
local mapSheet = sprite.newSpriteSheet("tilesetTest1.png", tileW, tileH)
local mapSet = sprite.newSpriteSet(mapSheet, 1, 4)
sprite.add(mapSet, "grass", 2, 1, 1)
sprite.add(mapSet, "ground", 3, 1, 1)
sprite.add(mapSet, "water", 4, 1, 1)
for j = 1, tileH+1 do
for i = 1, tileW+1 do
local s = sprite.newSprite(mapSet)
local which = math.random(3)
if which == 1 then
s:prepare("grass")
elseif which == 2 then
s:prepare("ground")
elseif which == 3 then
s:prepare("water")
end
s.x = i \* tileW - (tileW \* 0.5)
s.y = j \* tileH - (tileH \* 0.5)
end
end
To my eyes this should set each tile to the one I’ve picked in its set. Am I doing something wrong? I tried using a single set with all tiles in it, then picking the tiles with sprite.currentFrame but that left me with a black screen.
Thanks,
~ k [import]uid: 2857 topic_id: 1482 reply_id: 301482[/import]
