TexturePacker

Monkey Archive Forums/Digital Discussion/TexturePacker

ziggy(Posted 2013) [#1]
Is it worth it?


Tri|Ga|De(Posted 2013) [#2]
Yes!


ziggy(Posted 2013) [#3]
thnx!


rIKmAN(Posted 2013) [#4]
It's free isn't it, or do you mean time and effort?

Next time post less info, that took ages to read. :P


MikeHart(Posted 2013) [#5]
The pro version isn't free but it is worth every cent! Imho it is the best tool on the market for creating spritesheets.


Tibit(Posted 2013) [#6]
It is great!

Before I copied images manually to my monkey/graphics/ dir and did an optimized export to png before, cropped the image. Had to do this with every slight change made to an image.

Now I have a /Art/Game Projects/SuperCoolGame/ folder. In here I have all my images as fireworks layered pngs & psd files. I have added that folder to texture packer. After changing the "heavy" image I open texturepacker, click publish and the new texture (all textures!) is in game, optimized, trimmed edges (yet I still know the actual w/h).

What you get is:

1. Easier workflow
2. Game Loads faster
3. Reduce Render Calls (you still have to think about it, but it often makes it simple!)

I only wish I had been recommended it sooner. A must for all projects I do these day, even use it for projects in Flash Air.


ziggy(Posted 2013) [#7]
The only thing that worries me a bit is if there's any good loader for Monkey (I don't mind writing my own). I mean a loader that does not rely on a XML parser that creates garbage when it parses the document. Maybe a simple cvs file could do it?
I'll be purchasing it anyway, as it is damn cheap for the work it does.


therevills(Posted 2013) [#8]
There's a couple of loaders on here, including Diddy. Also the XML parsers don't really create garbage the Diddy one and Skn ones at least don't, which you can tell by the speed the parsing talked place.


Playniax(Posted 2013) [#9]
Ignition has also basic support for TexturePacker.


Tri|Ga|De(Posted 2013) [#10]
I use fantomEngine but if you look at this you can se my own code.


Skn3(Posted 2013) [#11]
The only thing that worries me a bit is if there's any good loader for Monkey (I don't mind writing my own). I mean a loader that does not rely on a XML parser that creates garbage when it parses the document. Maybe a simple cvs file could do it?
I'll be purchasing it anyway, as it is damn cheap for the work it does.


yeah therevills is right, the diddy and my xml module wont spam the gc. The only garbage created is with the disposable xml node structure. It would be pretty easy to make them keep a pool of reusable xml nodes. Probably not worth the optimization as you don't tend to constantly reload xml files during runtime.


Rushino(Posted 2013) [#12]
Interesting. I should have a look to this before my images getting too big.


ziggy(Posted 2013) [#13]
Thanks to all of you! I'll be packaing my game into textures very soon.


ziggy(Posted 2013) [#14]
Can't find a working TexturePacker loader. The one based on skn config.monkey xml loader seems to not be working becouse of the <? and ?> xml header. Before I spend some hours fixing it, does anybody have a working current-version texturepacker loader that works with some of the available texturepacker exports and is working with latest monkey version?


Beaker(Posted 2013) [#15]
You can strip the xml header (first line) and it should work fine.


ziggy(Posted 2013) [#16]
I know that, but it was also refusing to load. Not sure what's wrong yet. ?? Maybe something in my code.


Tibit(Posted 2013) [#17]
Standalone loader, from someone here in the community, not me.

textureLoader.monkey


Use like this:
[monkeycode]
Import textureLoader

Local ImageBank:TextureLoader = LoadAtlas("imageAtlas.png")
Local Player:Image = ImageBank.Grab("marine_shotgun", 0, Image.MidHandle)
[/monkeycode]


ziggy(Posted 2013) [#18]
Thanks Tibit!
While I was fighting how to use it I came up with this:
Import mojo
Import xmlloader

Class TexturePackerLoader
	Field images:StringMap<Image>

	Method New(path:String, filename:String)

		Local error:= New XMLError
		path = path.Replace("\", "/")
		If path.EndsWith("/") = False Then path += "/"

		Local buffer:String = LoadString(path + filename)
		Local doc:= ParseXML(buffer, error)
		If error.error = True Then Error Error(error.ToString)
		
		texture = LoadImage(path + doc.GetAttribute("imagePath"))
		If images = Null Then
			images = New StringMap<Image>
		Else
			images.Clear()
		EndIf
		For Local child:XMLNode = EachIn doc.GetChildren("subtexture")
			Local posX:Int = Int(child.attributes.ValueForKey("x").value)
			Local posY:Int = Int(child.attributes.ValueForKey("y").value)
			Local height:Int = Int(child.attributes.ValueForKey("height").value)
			Local width:Int = Int(child.attributes.ValueForKey("width").value)
			Local name:String = child.attributes.ValueForKey("name").value
			Local image:Image = texture.GrabImage(posX, posY, width, height)
			images.Add(name, image)
		Next		
	End
	
	Field texture:Image
	
End

And the xmlload import is just skn3 single-file xml parser that seems to work pretty well.