Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Clone animated sprite vs loadsubimage?

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 8th Dec 2011 00:26
I have a level building routine which uses
createsprite(loadsubimage()) to build the level from 32x32 blocks from a 256x256 tile sheet, with about 20 different tiles.

I will want to ad-hoc replace these blocks with any of 20 from the same sheet later, so is it:

1. better to create each sprite as above (200+) and reload a subimage each time I want to change it, or-

2. Load each tile with the 256x256 image as an animated sprite with an animation frame (effectively a 32x32 view of each tile) where I can set the frame using the sprite animation to quickly change the tile.

I currently use (1) but I would want to know that the 2nd method will not create 200+ instances of a 256x256 animation sheet in memory if I use CloneSprite() to display the repetitions.

Not being able to "copy/paste" an image and reading that the sprite engine is optimised for such things, I guess that (2) is the preferred option, but I can't see how 200+ sheets wouldn't be instantiated unless somewhere in the background of "clonesprite()" is just a pointer to the original image, thus being the best way forward with this.

LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 8th Dec 2011 01:35
My understanding is that we do not create copies of the images, and in fact reference the original image. If we do create identical copies of images, then it is clearly a waste of precious memory!

I drink tea, and in my spare time I write software.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 8th Dec 2011 02:07
I was hoping for a rather more confident assertion that this was the case

I don't have access to know what clonesprite() is doing behind the scenes, so was really just wanting some confirmation before I rewrite a fair amount of my game.

I am using method 2 for animating my main character, who has e.g. 40 frames of animation for each run, climb, idle and shoot situations but without using the copy/paste mentality, the clonesprite() method just has to use a reference to the image or we are all in big trouble

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 8th Dec 2011 09:39
I use method 2. It's very fast and convenient.
cloning is very fast, they are just duplicating the reference not the whole image, else you would ruin out of memory on mobile devices!

Login to post a reply

Server time is: 2024-11-22 20:02:53
Your offset time is: 2024-11-22 20:02:53