Sprite sheets
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 9358
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Sprite sheets
Ooooer . . . I am getting fed up of having to chop animated GIF images and sprite sheets
up into individual frames . . .
- -
Now . . . apart from the fact that an awful lots of ways to make games leverage sprite sheets
(which cuts down storage and speed overheads considerably) . . . it would be groovy if . . .
- -
one could use sprite sheets in LiveCode . . .
And here is where the Richmond Fantasy Thingy gets into high gear
and starts cooking up pseudo-code faster than you can say Sesquidepeleanism . . .
on mouseUp
set the backGroundPattern of grc "gFRAME" to the rect 0,175,0,286 of img "boy.png"
end mouseUp
Of course this isnae gonnae wark because when one
sets a backGroundPattern of a graphic object one has to reference the
image's ID rather than the image by name . . .
up into individual frames . . .
- -
Now . . . apart from the fact that an awful lots of ways to make games leverage sprite sheets
(which cuts down storage and speed overheads considerably) . . . it would be groovy if . . .
- -
one could use sprite sheets in LiveCode . . .
And here is where the Richmond Fantasy Thingy gets into high gear
and starts cooking up pseudo-code faster than you can say Sesquidepeleanism . . .
on mouseUp
set the backGroundPattern of grc "gFRAME" to the rect 0,175,0,286 of img "boy.png"
end mouseUp
Of course this isnae gonnae wark because when one
sets a backGroundPattern of a graphic object one has to reference the
image's ID rather than the image by name . . .
-
- Livecode Opensource Backer
- Posts: 9358
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Sprite sheets
This example uses individual images for each animation frame:
http://newsletters.livecode.com/may/iss ... tter4.html
and does the whole thing is a hugely over-complicated fashion anyway.
http://newsletters.livecode.com/may/iss ... tter4.html
and does the whole thing is a hugely over-complicated fashion anyway.
Last edited by richmond62 on Mon Jun 24, 2019 10:05 pm, edited 2 times in total.
-
- Livecode Opensource Backer
- Posts: 9358
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Sprite sheets
https://codeshack.io/images-sprite-sheet-generator/
"You can use your favorite coding language to select the coordinates of each image
and display them accordingly" . . .
http://www.html5gamedevs.com/topic/2690 ... -with-gui/
Well, for some daft reason my favourite coding language is LiveCode, but I cannot
for the life of me work out how to select the coordinates of part of an image and display
that is some sort of a frame (button, field, graphic object, image) somewhere else on a stack.
"You can use your favorite coding language to select the coordinates of each image
and display them accordingly" . . .
http://www.html5gamedevs.com/topic/2690 ... -with-gui/
Well, for some daft reason my favourite coding language is LiveCode, but I cannot
for the life of me work out how to select the coordinates of part of an image and display
that is some sort of a frame (button, field, graphic object, image) somewhere else on a stack.
-
- Livecode Opensource Backer
- Posts: 9358
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Sprite sheets
This is where I am getting in the sh*t:
as I seem unable to take a snapshot of part of an image.
Of course, in the end this is also useless because I should
be able to display part of a sprite sheet inside some sort of container without
having to make an intermediate image.
Code: Select all
import snapshot from rect (the rect 0,175,0,286) of img "boy.png"
Of course, in the end this is also useless because I should
be able to display part of a sprite sheet inside some sort of container without
having to make an intermediate image.
Last edited by richmond62 on Mon Jun 24, 2019 10:05 pm, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 9358
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Sprite sheets
Cripes:
https://pdfs.semanticscholar.org/8888/b ... 24ceb4.pdf
"Sprite sheets on which all sprites have identical
sizes are easy to be loaded by a game engine. In that
case, one simply needs to specify the x- and y-offset to
get a particular sprite in the sheet and the
corresponding size for that sprite sheet images."
So why does it seem difficult to specify the offset?
https://pdfs.semanticscholar.org/8888/b ... 24ceb4.pdf
"Sprite sheets on which all sprites have identical
sizes are easy to be loaded by a game engine. In that
case, one simply needs to specify the x- and y-offset to
get a particular sprite in the sheet and the
corresponding size for that sprite sheet images."
So why does it seem difficult to specify the offset?
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Sprite sheets
You could group the sprite sheet, set the group's clipsToRect to true.I should be able to display part of a sprite sheet inside some sort of container without having to make an intermediate image.
Then set the rect of the group to display part of the sheet (or set the hscroll/vscroll of the group if the rect's width/height is constant) .
shiftLock happens
-
- Livecode Opensource Backer
- Posts: 9358
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Sprite sheets
Thank you very much indeed.
That does work (although it involves a lot of fiddling around with numbers).
- -
Although, given the fiddling around that it involves
I wonder if it might not be better to "just" use individual files for frames.
The only advantage I can see about using a sprite sheet
is that the overhead in terms of file size should be considerably smaller.
-
That does work (although it involves a lot of fiddling around with numbers).
- -
Although, given the fiddling around that it involves
I wonder if it might not be better to "just" use individual files for frames.
The only advantage I can see about using a sprite sheet
is that the overhead in terms of file size should be considerably smaller.
-
- Attachments
-
- Sprite Sheet test.livecode.zip
- Here's the stack
- (235.41 KiB) Downloaded 162 times
-
- Livecode Opensource Backer
- Posts: 9358
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Sprite sheets
The "other" snag, and it is quite a significant snag, is this:
1. I made up that "Sprite Sheet" as a set of frames on
a transparent background (.png image).
2. "Normal" sprite sheets are not like that at all, but
generally have a checkered or solid colour background
that LiveCode is not going to ignore:
- -
therefore any sprite sheets for use with LiveCode have
to be specially created; which is just as much a fiddle as
setting up individual images for each frame.
1. I made up that "Sprite Sheet" as a set of frames on
a transparent background (.png image).
2. "Normal" sprite sheets are not like that at all, but
generally have a checkered or solid colour background
that LiveCode is not going to ignore:
- -
therefore any sprite sheets for use with LiveCode have
to be specially created; which is just as much a fiddle as
setting up individual images for each frame.
-
- Livecode Opensource Backer
- Posts: 9358
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Sprite sheets
I recently saw a demo of using a sprite sheet with a group doing the clipping and it worked well. I believe that the performance of that method is much better than you can get showing different images.
Brian Milby
Script Tracker https://github.com/bwmilby/scriptTracker
Script Tracker https://github.com/bwmilby/scriptTracker
-
- Livecode Opensource Backer
- Posts: 9358
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Sprite sheets
bwmilby
I am sure you are right.
My problem is how one can extract the sprites
surrounded by a transparent background when most
sprite sheets come with a one-colour background or
something checkered.
I am sure you are right.
My problem is how one can extract the sprites
surrounded by a transparent background when most
sprite sheets come with a one-colour background or
something checkered.
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Sprite sheets
Checkered usually indicates transparency. Or is it actually checkered when imported into LC? If so, send a bug report to the provider of the image, as such a background would make the image useless.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn