inserting sprites into a table, how ?

Hi,
using the search faciltiy has proved less fruitful than I had hoped.
I would like to insert sprites into a table.
Now I can do this with static images/objects but I cant quite figure out how to it with sprites.
I can do it singularly on each spritesheet with no issues.
I can use spritesheets fine it is the table I am having trouble with.

I figure I declare each of the newImageSheets ( there are 4 in this case) outside of the table and then place a reference to each in the table.
I am lost as to where to place the actual sprite sequence data, really the logic of the process is perplexing me.

any pointers or how to approach the logic would be great.
[import]uid: 127675 topic_id: 33205 reply_id: 333205[/import]

Not really sure what table type you mean?

  1. display.newSprite() objects are the same as anything else from display.* - you can insert them into displayGroups using :insert()

  2. The sprite sequence and image sheet data is just that; data. Neither is a display object so you can only organize those using regular tables.

ie here’s something I commonly do:

[code] – data.lua, a lua file that I just use to store static information
local p = {}

p.sequence = {}
p.sequence.coolguy = {} – put your sequence data in here

p.sheet = {}
p.sheet.coolguy = graphics.newImageSheet() – put your image sheet commands in like this (with the settings, of course)

return p

– Then, to call this from any other lua file…

local data = require(“data”)

local myRandomNPCDude = display.newSprite(data.sheet.coolguy, data.sequence.coolguy)[/code]

  1. Another approach is just to attach your regular tables to the display object. (display objects are still technically tables, so you can always add regular tables to them)

[code]local group = display.newGroup() – the group holding all your sprites
group.sequence = {} – put your sequence data here
group.sheet = graphics.newImageSheet() – put your imageSheet data here

local myRandomNPCDude = display.newSprite(group, group.sheet, group.sequence)[/code] [import]uid: 41884 topic_id: 33205 reply_id: 131930[/import]

Not really sure what table type you mean?

  1. display.newSprite() objects are the same as anything else from display.* - you can insert them into displayGroups using :insert()

  2. The sprite sequence and image sheet data is just that; data. Neither is a display object so you can only organize those using regular tables.

ie here’s something I commonly do:

[code] – data.lua, a lua file that I just use to store static information
local p = {}

p.sequence = {}
p.sequence.coolguy = {} – put your sequence data in here

p.sheet = {}
p.sheet.coolguy = graphics.newImageSheet() – put your image sheet commands in like this (with the settings, of course)

return p

– Then, to call this from any other lua file…

local data = require(“data”)

local myRandomNPCDude = display.newSprite(data.sheet.coolguy, data.sequence.coolguy)[/code]

  1. Another approach is just to attach your regular tables to the display object. (display objects are still technically tables, so you can always add regular tables to them)

[code]local group = display.newGroup() – the group holding all your sprites
group.sequence = {} – put your sequence data here
group.sheet = graphics.newImageSheet() – put your imageSheet data here

local myRandomNPCDude = display.newSprite(group, group.sheet, group.sequence)[/code] [import]uid: 41884 topic_id: 33205 reply_id: 131930[/import]

I use level director to configure my sprite sheets and animations and it creates the lua code for me.
It even allows you to setup all physics properties including shape and collision settings.
This might save you some time and you can learn from the code.

Level director is at www.retrofitproductions.com there is a free version but only works on windows.
[import]uid: 104325 topic_id: 33205 reply_id: 132524[/import]

@Rich,

thanks for that it kind of answered my question, ( I could have been clearer ); put me on the correct path of how to implement what I required anyway.

[import]uid: 127675 topic_id: 33205 reply_id: 132581[/import]

I use level director to configure my sprite sheets and animations and it creates the lua code for me.
It even allows you to setup all physics properties including shape and collision settings.
This might save you some time and you can learn from the code.

Level director is at www.retrofitproductions.com there is a free version but only works on windows.
[import]uid: 104325 topic_id: 33205 reply_id: 132524[/import]

@Rich,

thanks for that it kind of answered my question, ( I could have been clearer ); put me on the correct path of how to implement what I required anyway.

[import]uid: 127675 topic_id: 33205 reply_id: 132581[/import]