SpriteGrabber class -SpriteSheets in 2 lines

Okay scratch my previous question, turns out it was a problem with my collision handling.

Another question though, given your experience with your own library, what would be the best way to go about linking it to physics bodies?

Using SDK’s physics.addBody, that limits me to either a circular shape, or a custom shape definition that makes do for all the sprites in the spreadsheet. Is there (or will there be) a way to use different shapes for different animations, or will I have to create different instances using grabSprite, and then assign different shapes to them? [import]uid: 63884 topic_id: 3197 reply_id: 39436[/import]

Hi there,

I am not using physics in my project, so I am not the best source for help on this one.

However, from what I have seen the SDK uses a single shape for all the images of a sprite. So the only way to go is to have same dimensions for all of your frames inside each animation. This is not very flexible, I know…

Now, regarding your question, I thought you can easily assign different bodies for different sprites within a spritesheet. Isn’t this the case with the current SDK?
Pay attention to this please: a spritesheet has one or several sprites inside it and each sprite can be consisted of either a single (1) frame (e.g. an icon) or a series of related frames that make an animation. Collections of frames (images) constitute logical sprites and sprites are stored in a spritesheet.

Now, I think you can add a different physics body for each sprite in the spritesheet. The constraint is that you can’t add a different body for each frame of a sprite.

PS: Have in mind the sprites+physics bugs I’ve mentioned in my previous post. [import]uid: 7356 topic_id: 3197 reply_id: 39505[/import]

If I have a drag function to an object, is it possible to play a sprite while its being dragged and stop when you let go. I tried to do this and it doesn’t seem to work properly… Can anybody help me with this. [import]uid: 51459 topic_id: 3197 reply_id: 39701[/import]

@Magenda Thanks for the reply, I’ve taken a closer look at the sprite API and yes, you’re right.

@jakescarano

Given that you have an instance of a sprite from SpriteGrabber, I imagine it would be something like this

[code]
local onDrag = function (event)
if event.phase == “began” then
event.target:playClip (“myDragAnimation”);
elseif event.phase == “moved” then
event.target.x = event.x;
event.target.y = event.y;
elseif event.phase == “ended” or event.phase == “cancelled” then
event.target:playClip (“myIdleAnimation”);
end
end

myObject:addEventListener (“touch”, onDrag);
[/code] [import]uid: 63884 topic_id: 3197 reply_id: 39723[/import]

@Magenda, Hi…

Thanks a lot for you effort for the SpriteGrabber. Since it’s very useful for me, I can’t resist to use in my project. However, I’m having problem when I have to use “newSpriteMultiSet”. SpriteGrabber doesn’t support “newSpriteMultiSet” but most of my codes are written with SG. So I’m having a hard time here. Do you have any plan to support that feature?

Thanks. [import]uid: 9137 topic_id: 3197 reply_id: 44806[/import]

Hi

I’ve just got a quick question about drawing order

I’m doing an isometric-esque(!) game so everything has to be drawn from backish to frontish, whilst being animated

the only thing is, even calling show() will change the position but maintain the same drawing order, so if y-positions have changed since the last frame things are being drawn over something instead of behind it

BUT if i re-call (whatever):grabSprite which seems to be the only way to bring this to the front of the screen, I then lose the current frame of animation that was being played

Is there another way of re-drawing existing sprites so that I can change their drawing order that I haven’t tried here?

TL:DR- need to bring sprites to front or send to back relative to each other while redrawing, and they may be in the middle of an animation at this point

so far though it’s an awesome script, I love the integration with texturepacker just to complete it all so i don’t have to write my own this time!

cheers :slight_smile: [import]uid: 71799 topic_id: 3197 reply_id: 51639[/import]

got a cheap and safe hack that’ll work just the same anyway so don’t worry if it’s unsupported like… [import]uid: 71799 topic_id: 3197 reply_id: 51647[/import]

@paingpyi

Thanks for your kind words.

I was always sceptical about the point of grabbing sprite frames from several sheets, so I never used this feature in my project and thus I am kind of reluctant to implement it in SpriteGrabber.

I mean, the point of using sprite sheets is to have a group of graphics, that you are going to use in a game section, permanently loaded on memory and quickly readable. If you know that you are going to need spriteX inside a specific level, why don’t you just add it to that level’s sheet?

By calling sprites from different sheets that also include sprites which you are not going to use in a specific level, you are wasting a big amount of memory, since all the involved sheets (sheets, not just sprites) are being loaded in advance. It is much better to have a sprite included in several sheets, than loading a whole sheet to just get access on a subset of it. Most of the times, RAM (sheets in memory) is a more valuable resource than storage memory (app filesize).

Having said that, I always build my sheets not concept-wise but instead usage-wise, so that anything that I use in several sections in my game is always included in a general sheet that I load from the start of the game and keep it loaded until exit. Level sheets only include graphics that are not going to be used elsewhere in the game. This way, I keep assets memory to the minimum.
Cheers

PS: Have you ever played Zombieville USA? This game (made with Unity) has all of its assets included in a single spritesheet for performance reasons. Each separate sheet you are using costs an additional “draw” call to the GL engine. Have in mind that a good performing game has to have bellow 30 draw calls and each “display” object (image, textfield, shape, sheet) you are using is an additional draw call. [import]uid: 7356 topic_id: 3197 reply_id: 45396[/import]

This might be an old place to ask but your the big cheese of spriteGrabber.

Is there a way i can use multiple spritesheets for a single character?

I would LOVE to put them all into 1 spritesheet per character but as i understand there’s a 1024 x 1024 texture memory limitation? [import]uid: 91798 topic_id: 3197 reply_id: 58205[/import]

@ thehivetyrant you should try Sprite loq. I use it every day doing exactly what you had explained! [import]uid: 51459 topic_id: 3197 reply_id: 58218[/import]

I’m using Texture Packer, isn’t it the same?

My issue is having my character change to different spritesheets for more animation in my code, not the organisation of the spritesheets.

I am right in thinking there’s a size limit of 1024 x 1024 for spritesheets right?

Or am i misunderstanding what Sprite loq is? [import]uid: 91798 topic_id: 3197 reply_id: 58222[/import]

Sprite loq makes it easy to combine many sprite sheets to one project… Also the support is awesome he gets back vary quickly. Thats if you use flash for your animations… [import]uid: 51459 topic_id: 3197 reply_id: 58244[/import]

I totally agree with @jakescarano. If your animation is created using Flash, Spriteloq is the way to go. [import]uid: 67217 topic_id: 3197 reply_id: 58249[/import]

Well - you can use TexturePacker too. With the current version you can drag in flash files and the animations will be decomposed as single sprites. It works fine with windows.

The mac version is not officially released since there is a problem with 64 bit applications - they can’t use the 32bit flash version… I am currently working on a solution for that.
[import]uid: 9611 topic_id: 3197 reply_id: 58254[/import]

Could you give some more examples on how to check if a sheet eg. mySheet = grabber.grabSheet(“mySheet_sheetfile”) has been unloaded? At the moment, as far as I understand, even after a sheet is removed mySheet will still exist as a variable/table. I want to make sure that I don’t call a grabSheet if the sheet has been loaded already, but at the moment I’m not 100% sure how to test that it’s really empty. The assert function seems a bit drastic. Should I check for number of children of a specific table? [import]uid: 83823 topic_id: 3197 reply_id: 67168[/import]

Hi Magenta, I’m new to sprtitegrabber and was interesting in the ability to create different clip from a sheet.
Working on the sample uma sheets I tried the following :

local grabber = require("SpriteGrabber")  
   
local umaSheet=grabber.grabSheet("uma")   
local horse=umaSheet:grabSprite("",true,{ run={1,8,1000,0}, boo={1,8,1000,0} } )   
horse:playClip("run") -- works  
  
local clumsyhorse = umaSheet:grabSprite("01,03,05,07",true,{ run={1,4,1000,0} } )   
clumsyhorse:playClip("run") -- fails ...   

The point is to make a clip from different images taken in the sheet, why my clumsy horse does not run ?

thx [import]uid: 9328 topic_id: 3197 reply_id: 81655[/import]

Hey,

I love SpriteGrabber but I’m having a problem… No matter what I set the “speed” of the animation clip to, it is always the same speed. Why even have a speed if it doesn’t affect the speed of the animation clip? What am I doing wrong?

[lua] local explosion = explosions:grabSprite("",false,{smoke={1,21,2000,1},fire={22,21,2000,1},water={43,21,2000,1},toxic={64,21,2000,1},zap={85,21,2000,1}});[/lua] [import]uid: 63800 topic_id: 3197 reply_id: 83039[/import]

I was wondering if it is possible to extend the SpriteGrabber Lib by adding support for sprite.timeScale in order to change the speed of the object. I would also like to know if there is a better way to remove a single sprite item and not the whole sheet.

[import]uid: 63800 topic_id: 3197 reply_id: 83895[/import]

@mike
check the way you are starting the clip to play it should be
ex.
explosions:playClip(“smoke”)

notice playClip not just play
i made this mistake once and it caused the speed to not work [import]uid: 7911 topic_id: 3197 reply_id: 83907[/import]

@stefan27

I wouldn’t worry about this. In case a sheet is already loaded, the engine understands this and doesn’t load anything again. You can test the validity of this by inserting a grabSheet statement inside a “for” loop. [import]uid: 7356 topic_id: 3197 reply_id: 83972[/import]