Texture Atlas with TexturePacker

Monkey Forums/Monkey Programming/Texture Atlas with TexturePacker

erebel55(Posted 2014) [#1]
I searched around the forums and found this thread
http://www.monkey-x.com/Community/posts.php?topic=1216

So, I took the penguin image from there, added it to TexturePacker and set the following settings.


Which generated the following the following penwalker.png file


And the following penwalker.txt file


From here I created the following from Adam's Another Texture Atlas Loader
textureloader.monkey


I then took therevills example and created the following
textureloadertest.monkey


However, I am getting the following when I try to run.
Loading new texture penwalker.png here, index 0
walker
**atlas not found:00
**atlas not found:01
**atlas not found:02
**atlas not found:03
**atlas not found:04
**atlas not found:05
**atlas not found:06
**atlas not found:07
**atlas not found:08
**atlas not found:09
**atlas not found:10
**atlas not found:11
**atlas not found:12
**atlas not found:13
**atlas not found:14
**atlas not found:15
Monkey Runtime Error : Memory access violation
C:/MonkeyXPro78c/modules/mojo/graphics.monkey<457>
C:/Users/Ethan/Dropbox/textureloadertest.monkey<50>
C:/MonkeyXPro78c/modules/mojo/app.monkey<113>


So I am assuming I did something wrong in TexturePacker?


AdamRedwoods(Posted 2014) [#2]
according to the "penwalker.txt" file, you only added one file, so the texture atlas only sees the one.
in this case, you do not need the texture atlas loader. instead use this, which is in Monkey:
myImage = LoadImage ( path:String, frameWidth:Int, frameHeight:Int, frameCount:Int, flags:Int=image.defaultflags )

where frameWidth=32 and frameHeight=32 and frameCount=16
then use
DrawImage(myImage, x, y, your frame number)



erebel55(Posted 2014) [#3]
Right, I understand how to do LoadImage/DrawImage; that is what I'm currently using in my game.

I am trying to understand how to use atlases. So for animated images I have to add each frame as a separate image to TexturePacker? I just added the whole frame strip.


AdamRedwoods(Posted 2014) [#4]
So for animated images I have to add each frame as a separate image to TexturePacker?

yes. then the "atlas.Get()" filename would be the names of the files you added.


erebel55(Posted 2014) [#5]
Thanks I got it working now :D