Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Tiarny

Pages: [1]
1
Support / Trying to read sprite pixel data from an atlas
« on: August 14, 2013, 05:53:25 pm »
I'm currently using the 2DToolkit for all my character animations and sprites, but I have created an "explosion" system which causes the characters to break into their individual pixels upon certain game over states. To make it more dynamic I want to be able to iterate through each pixel of a sprite and find its colour, mapping it to the individual "pixel" that will then explode. This way, with a bit of smoke and mirrors in hiding the actual sprite, it looks like the actual character sprite is exploding apart.

My current thinking is that the best way to do this is to simply ready directly from the sprite / atlas in some way, but I'm not sure the best way to go about it. I was looking through the documentation but I got a bit muddled, so I was hoping someone might be able to point me in the right direction.

I know directly reading is probably not the most efficient way of doing things, but the character atlases are only 128*128 (256*256 in some cases) and each individual sprite is only about 30*80 so it seems like a better way of doing it than trying to manually build "pixels" for every possible sprite each character has.

So, basically - A dynamic way of getting the colours for the current sprite for the current character from the atlas, so I can apply those same colours to an explosion system!

Thanks.  :D

2
I've got some sprites in my scene of various different shapes and I want to detect which one the user is currently hovering over, but only when they are hovering over the "visible" parts of a sprite.

It is easy enough to do a bounding box check to see which sprite the mouse is currently over, but the problem is that this doesn't handle transparency. I was trying to think of the best way to handle this and I believe it would be to pull colour information for the sprite, as then I could do a simply check on the pixel co-ordinate to see if the current part of the sprite is transparent or not. If it is transparent then I can ignore it.

I believe what I need is a way to check the material on the atlas for my sprite, but to do that I would need some kind of bounding rectangle that tells me where my sprite is saved on the atlas (I think, but I might be wrong). Is it possible to get this information from the sprite itself?

3
Support / How do I manually WordWrap my text in a Text Mesh?
« on: August 09, 2012, 05:17:24 pm »
I have a feeling I'll kick myself when I get the answer to this. I'm currently trying to load in strings from a script and I want to add line breaks to format the text correctly when a single line is too big to fit within the given area. I can easily create multi-line text for the tk2dTextMesh using the Unity editor, but I can't seem to find the correct return character to do it when creating text in my scripts. What would be the best way to implement this?

I was reviewing the documentation on the site before posting my query and I noticed that there were some properties (formatting & wordWrapWidth) on there that I can't currently seem to access in my own scripts. I'm running 1.76 final + Patch 1, so I was wondering if that is something coming in a future update or if I was just overlooking something.

Thanks for your help! It's a great toolkit, and has really sped up development here.

Pages: [1]