spritesheet.lua file (Where to get it?)

Hello all I am trying to use a sprite sheet for some character animations. When I try to use it the console says it can’t the lua file. I am a bit confused at how to get a spritesheet.lua from my spritesheet.png file I am using. I am extremely new to sprite sheets and any advise would be helpful. [import]uid: 49863 topic_id: 17730 reply_id: 317730[/import]

Hey crazypsycho, you need to require sprite to use it:

[lua]local sprite = require(“sprite”)[/lua]

You might want to read this too, which describes how Sprite API works:

http://developer.anscamobile.com/reference/sprite-sheets

Naomi [import]uid: 67217 topic_id: 17730 reply_id: 67557[/import]

Thank you Naomi, I did that. The specific error I am getting is…

no field package.preload[‘swim_sheet’]
no file ‘C:\Users\Chris\Desktop\NCG\code\swim_sheet.lua’

[import]uid: 49863 topic_id: 17730 reply_id: 67560[/import]

Hey crazypsycho, do you use any tool to generate spritesheets? I use Spriteloq, and it automatically generates a lua file that accompanies the png file. If you don’t use any tool, I think you need to generate your own sprite sheet descriptor file. I could be wrong, but the quick look at the reference link seems to suggest the need for it. Did you read the reference link?

http://developer.anscamobile.com/reference/sprite-sheets

Naomi [import]uid: 67217 topic_id: 17730 reply_id: 67563[/import]

I will have to check with my artist. I doubt he got that file when he created it though or he would of sent it with the spritesheet. Do you know of any free tools that will generate both files like that?
[import]uid: 49863 topic_id: 17730 reply_id: 67566[/import]

Crazypsycho, once I started using Spriteloq, I haven’t look for any other. So, I don’t know how other ones work…

Naomi [import]uid: 67217 topic_id: 17730 reply_id: 67581[/import]

Crazy,

I would recommend using Zwoptex. What I always do is make a series of PNG’s, then putting them into Zwoptex (it’s free). Then I export the sprite sheet as a .png and then add this code:

[lua]local loading = sprite.newSpriteSheet( “LoadingCircleOld.png”, 102, 102 )

local spriteSet2 = sprite.newSpriteSet(loading, 1, 8)
sprite.add( spriteSet2, “LD”, 1, 8, 200, 0 )

local loadingSprite = sprite.newSprite( spriteSet2 )
loadingSprite.x = _W/2; loadingSprite.y = _H/1.15
loadingSprite.xScale = .7; loadingSprite.yScale = .7
loadingSprite.alpha = .5

loadingSprite:prepare(“LD”)
loadingSprite:play()
loadingSprite:pause() [/lua]

Hope this helps. Make sure to adjust the resolution per image in the png sprite sheet.

Regards,
Jordan Schuetz
Ninja Pig Studios [import]uid: 29181 topic_id: 17730 reply_id: 67648[/import]

Thanks everyone for the advise. Spriteloq requires the use of flash files and Zwoptex seems to only exist for mac. I should of said that I am using the Windows operating system. If anyone has any ideas on this please let me know. I am at a loss for now. [import]uid: 49863 topic_id: 17730 reply_id: 68996[/import]

Oh and sorry for the delayed response on here. I have been working long days. [import]uid: 49863 topic_id: 17730 reply_id: 68997[/import]

Alright I got the spritesheet.png and .lua files in the code and I am not receiving any console errors. However my sprite is not appearing on the screen.

[code]function newSwimmingSprite()

local swimming = sprite.newSprite(spriteSet2)
swimming:prepare(“default”)
swimming.isHitTestable = false
print (“gotit”)
return swimming
end

local function spawnPlayer( event )

local swimming = newSwimmingSprite()
swimming.x = display.contentWidth / 2
swimming.y = display.contentHeight / 2
swimming.xScale = .7
swimming.yScale = .7
swimming:play()
print (“spawnedPlayer”)
end

– INITIALIZE
local initVars = function ()
– Inserts
localGroup:insert(image1)
localGroup:insert(image2)
localGroup:insert(image3)
localGroup:insert(image4)
localGroup:insert(image5)

– Positions

– Colors

– Listeners

swimming = sprite.newSpriteSheet( “swim.png”, 1, 3 )
spriteSet2 = sprite.newSpriteSet(swimming, 1, 3)
sprite.add( spriteSet2, “default”, 1, 3, 1000, 0 )
spawnPlayer()
end
this is all of my code that involves the spritesheet. If anyone has any Ideas I would appreciate hearing them. [import]uid: 49863 topic_id: 17730 reply_id: 69231[/import]

Got it. Thank you all for your help. [import]uid: 49863 topic_id: 17730 reply_id: 69244[/import]