Skip to main content
GameDev.net gamedev.net
🔒 Locked

Creating many spriteSheets with same Texture2D

Started by AndersEkdahl Feb 22, 2012 at 12:18 PM 3 replies 1.7k views
Original Post
AndersEkdahl
AndersEkdahl
Hello.
I'm trying to draw a couple of different spritesheets using the same Texture2D, but as you may already understands, different sprites have different frames etc. So this does not work as I intended it to do.
Is there some way to use the same Texture2D and have different settings for different sheets? I don't want to create different textures for all enemies.
NickGomes
NickGomes
You would have to create a Sprite Map in some format (XML is a good choice). This map would define the location and size of each frame of each animation that's in your spritesheet. This gives your animations and spritesheets more flexibility as you don't need to follow a strict size/placement/number for each frame. In addition you can easily re-use sprites during animations.

So an example spritesheet map:

<Object name="Enemy1">
<Sprites>
<Image id="1" x="5" y="5" height="64" width="64"/>
<Image id="2" x="69" y="69" height="102" width="50"/>
</Sprites>

<Animations>
<Animation name="attack" fps="30" numFrames="3" loop="no">
<Frame sourceID="1"/>
<Frame sourceID="2"/>
<Frame sourceID="1"/>
</Animation>

<Animation name="Idle" fps="30" numFrames="1" loop="yes">
<Frame sourceID="1"/>
</Animation>

</Animations>
</Object>
meeshoo
meeshoo
A while ago I was using HGE game engine and they have a custom resource script that they use to load your resources. Maybe if you take a look at their format you would get an idea how to do yours: http://hge.relishgames.com/doc/index.html, choose "hgeResourceManager" on the left menu and then "Resource script" from the related information on that page.
AndersEkdahl
AndersEkdahl
Thx for the replies!
I figured out a way to do this by just creating a big spritesheet and jump between different rows of the sheet, with Points. Works great

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.