Unity : DrawTextureWithTexCoords Example and Tutorial

A few weeks earlier I was confused in how to use the DrawTextureWithTexCoords, searching with google gave no results, yes there are fews example and perhaps tips, but those are unclear to me.

Fortunatelly after trial and error, I finally understand how this function really works, stick to me for more explanation.

Unity Documentation :

DrawTextureWithTexCoords(Rect position, Texture image, Rect texCoords, bool alphaBlend = true);

Position : Rectangle on the screen to draw the texture within.
Texture : Texture to display.
texCoords : How to scale the image when the aspect ratio of it doesn’t fit the aspect ration to be drawn within.
alphablend : Whether to alpha blend the image on to the display (the default). If false, the picture is drawn on the display.

For more simple explanation,

Continue reading »

Unity : blue background when playing the scene


A few days ago, I got stuck in some problem.. it wasn’t so hard, the rendered game and executable unable to show me the background image, it’s just showing blue background and my sprite stuck in the middle.

Googling to find what the problem doesn’t show any results, until I got advice to restart unity… and problem was solved.

It seems unity had a bug that making the background image not showing in render game or executable compiled, the solution is actually simple, just restart the Unity and voila problem solved..

As for the sprite that stuck on center, just by check the root in the sprite solved the problem..

Oh yeah, I’m trying to learn how to use unity and blogging it as a reminder for many problem that may show up.. or just using it to store code library ?

Continue reading »

How to use animation offset in libgdx from texturepacker

While trying some new things after working all days, I encountered something annoying .. when I used texturepacker gui from codeandweb, the packer packs my image into one and use offset to maximize its compression.

This kind of packing is actually good, but it’s a little annoying because we must set the offset in libgdx to actually make the animation position line-up.

Packed by texturepacker
Packed by texturepacker

I browsed through google to find how to actually get the offset and apply it to the animation function in libgdx, but luck not in my side for a whole day … ah, as reminder I used this code to apply rotation from the left bug, because if you used the sprite as it is, you will get the same as the sprite above for animation.

Continue reading »