Does anyone have a sprite sheet example project that you wouldn't mind sharing with me?

Title says it all… I’m super confused and cant really wrap my head around it… And no please don’t suggest the corona sample projects i have looked those over and don’t understand them…

I just want something very simple with a couple frames?..

Thanks!

What tool are you looking to use?  You’ll generally need to use a tool to create sprite sheets.  You can make sprites and sheets w/o a tool, but a tool makes life easier.

I personally use: Texture Packer.

Well i don’t think i made myself fully clear but what i wanted was a sample project ready and showing how to sprite is working… with lets say an image like this (below)

Hi @SonicX278,

Well, the first thing you need to understand is image sheets, because that is the foundation of sprites as well. What is your level of understanding on image sheets?

Brent

I understand fully how sprites work and stuff i just cant get one to work for me in my code…

I guess I don’t understand the question.

Here is a simple sprite example: http://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/09/sprites.zip

I used Texture Packer to put the sprites in the sheet and generate the info file.  I know how to do that manually, but I don’t bother. That’s what I use tools for.

Hope this helps a little.

Thanks RoamingGamer! Thats exactly what i needed! Now i got to look over the files and now im 80% sure i got this whole sprite thing. Haha

Thanks Again!

Here is another example with more sprites, including yours:

http://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/09/spirtes2.zip

This one uses SSK, but there is still some info there you should be able to extract right away.

Hey RoamingGamer… I’m having a hard time removing the SSK and putting everything in one lua file? or two lua files easier? As i’m going to have many many sprites…

Heres what i want BUT without the SSK…

http://www.mediafire.com/download/cjj334zmds8d8nd/spirtes2.zip

That looks like the sample I sent.

However.  Forget about the second example except these two files:

  1. sonic.lua
  2. sonic.png

I don’t think the SSK sprite stuff will help you.  I merely included it because I didn’t want to bother writing the whole example to show you your sprite in action.  You’ll be better off using the above two files and trying to use what I showed in the sprite1.zip project.

-Ed

Yes it is the sample you sent me and I’ve been trying to remove the SSK for nearly an hour and it’s really getting to me  :angry: I just cant seem to get it to work.

OK.  I just updated the first example to include your sprite.  Please re-download this:

http://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/09/sprites.zip

Yeah, it wouldn’t be an easy change.  That one line of code does a LOT of heavy lifting:

local tmp = newSprite( group, centerX, centerY - 110, "sonic.png", { frames = { 1,2,3,4,5 }, time = 5 \* 150, loopCount = 0 }, { autoPlay = true, scale = 2 } )

SSK isn’t really designed to be reverse engineered or de-intertwined. It saves me hours of code writing because its a total toolkit for most things I do all the time.  I’ve put hundreds of hours (probably more) into adding features so you can replace dozens of lines with a single line… 

So, I probably should not have used it to help show you more about sprites… that piece of the kit (SSK) is a bit deep.

Hey would you mind really quikly in simple terms explaining the code??

Main.lua

local sonicInfo = require "sonic" local sonicSheet = graphics.newImageSheet("sonic.png", sonicInfo:getSheet() ) local sonicSeqData = { {name = "explode", frames = {1,2,3,4,5}, time = 500, loopCount = 0, loopDirection = "forward"}, } -- Create sprite, play 'leftwalk' local tmp = display.newSprite( sonicSheet, sonicSeqData ) tmp.x = display.contentCenterX tmp.y = display.contentCenterY tmp.xScale = 3 tmp.yScale = 3 tmp:setSequence( "explode" ) tmp:play() display.newText( "sonic (explode)", tmp.x, tmp.y + 70, native.systemFontBold, 30 )

Sonic.lua

local SheetInfo = {} SheetInfo.sheet = { frames = { { x=1, y=1, width=20, height=20, }, { x=21, y=1, width=20, height=20, }, { x=41, y=1, width=20, height=20, }, { x=61, y=1, width=20, height=20, }, { x=81, y=1, width=20, height=20, }, }, sheetContentWidth = 100, sheetContentHeight = 21 } SheetInfo.frameIndex = { ["frame1"] = 1, ["frame2"] = 2, ["frame3"] = 3, ["frame4"] = 4, ["frame5"] = 5, } function SheetInfo:getSheet() return self.sheet; end function SheetInfo:getFrameIndex(name) return self.frameIndex[name]; end return SheetInfo

I just want a further explanation on how the mail.lua knows what sonic .lua is supposed to do and then what the function in sonic.lua do?

Thanks!!

And can i get the sonic.lua and just out it into main.lua to have just 1 file?

NVM i got this question to work…

I really don’t have any more time tonight.  

Yes, you can incorporate the content of sonic.lua into main.lua.  You can even generated the contents dynamically if you want.

I’d suggest reading the docs on all corona functions used and follow up by looking through the tutorials on the site. 

The problem is, there isn’t just one way to do sprites, and I’m pressed for time right now.  If you’re still stuck tomorrow afternoon I’ll see what I can do.

-Ed

Actually i got exactly what i wanted it to do and everything is working!!

Thanks a million!!

-SonicX278

Kudos to roaminggamer for helping out. Nice :slight_smile:

By the way, SonicX278: the sooner you get to splitting everything up into different files, the better your code will become!

Actually that’s exactly what I thought last night! Everything will be cleaned and easier in my opinion.