Manipulating 2D Spritesheets in code
by Anthony Ross · in Torque X 2D · 10/11/2009 (6:17 am) · 7 replies
Torque X 2D
Can anybody help me?
I can't find any code that shows how to load mySpriteSheet.png in code and then show say frame 7.
Which functions allow us to set the splitting of an image into sprite frames.
Is their detailed documentation on Static and Animated Sprites somewhere?
I have the Complete Guide to Torque X book but it isn't in there as far as I can see.
Thanks
Can anybody help me?
I can't find any code that shows how to load mySpriteSheet.png in code and then show say frame 7.
Which functions allow us to set the splitting of an image into sprite frames.
Is their detailed documentation on Static and Animated Sprites somewhere?
I have the Complete Guide to Torque X book but it isn't in there as far as I can see.
Thanks
#2
10/11/2009 (3:59 pm)
I have done a simple animation in code(I learned it straight from the xml that the builder spits out)GarageGames.Torque.Materials.SimpleMaterial spriteMaterial = new GarageGames.Torque.Materials.SimpleMaterial(); spriteMaterial.TextureFilename = "data/images/Player/InvulnAnimation.png"; spriteMaterial.Name = "InvulnAnimationMaterial"; GarageGames.Torque.Materials.CellCountDivider cellDivider = new GarageGames.Torque.Materials.CellCountDivider(); cellDivider.CellCountX = 2; cellDivider.CellCountY = 1; spriteMaterial.TextureDivider = cellDivider;That sets up my material, where I have a 2 frame animation that is right next to each other. It's not too complicated to mess with the animated and static stuff after you do that.
#3
See my game Meet UR Match on XBLIG
10/12/2009 (10:42 am)
I was wanting to make a Graphic Font printing system for game info and menus and saw this as the first step to getting my own custom fonts in.See my game Meet UR Match on XBLIG
#4
10/12/2009 (11:18 am)
Anthony: XNA has a font system already and you can load your own custom fonts in bitmap form - which should save you a lot of work making your own text display system. There are one or two threads in the forums about it.
#5
10/12/2009 (1:52 pm)
Hi Duncan ... I already have it in plain XNA in my game but I didn't think I could use that in Torque especially in the GUI. Are there any references on mixing Torque X and normal XNA code?
#6
But, if you need to do some pure XNA rendering (e.g. to put text on different layers in the scene) then try this thread for some pointers:
www.garagegames.com/community/forums/viewthread/102923
10/12/2009 (5:41 pm)
The Torque GUI uses XNA fonts anyway, so you can use a custom XNA bitmap-based font no problem.But, if you need to do some pure XNA rendering (e.g. to put text on different layers in the scene) then try this thread for some pointers:
www.garagegames.com/community/forums/viewthread/102923
#7
Thanks Again!
10/12/2009 (8:07 pm)
Thanks for all the help so far Duncan. I'll be looking into those leads tomorrow night. Thanks for the code also Christopher! Any other leads that I should chase up?Thanks Again!
Torque Owner Duncan Colvin
The documentation does not cover this, but if you have the version of TX with the source code you can look in the relevant classes and you will see what stuff you need to do.