Skip to content

Instantly share code, notes, and snippets.

@jeiting
Created March 27, 2013 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeiting/5258112 to your computer and use it in GitHub Desktop.
Save jeiting/5258112 to your computer and use it in GitHub Desktop.
-- How I want to use Sprites
-- By: Jacob Eiting
--[[ File system contents
main.lua
faces.lua
faces-hd.lua
faces.png
faces-hd.png
pop.png
pop-hd.png
kansas/
logo.png
]]
-- load a sprite sheet
Sprite.loadSpritesheet("faces")
-- create a sprite from that sheet
local jacob = Sprite.spriteWithName("jacob.png") -- returns a moai prop with all the write stuff
local aaron = Sprite.spriteWithName("aaron.png")
-- create a sprite from a file
-- checks the cache, if no frame, hit the file system
-- this will load the file and make it a texture and create a 'frame' and add it to the cache
local pop = Sprite.spriteWithName("pop.png")
-- this will create a second sprite using the same texture created in the previous step
local pop2 = Sprite.spriteWithName("pop.png")
--[[
How we implement this with decks is yet to be decided. We need to also consider frame animations and how to most easily achieve those in MOAI.
]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment