- Home /
How to Get Image edge size 2D??
Hello guys, i'm trying to make an algorithm to create procedural scenery, and need to spawn the next sprite right at the end of last sprite, that i got, but i need to spawn in the right height too..
I need to get the lateral collidable height of my sprite, like this:
Answer by etopsirhc · Jul 18, 2015 at 08:30 PM
i'm guessing you are using a tile sheet and semi-randomly placing them next to each other at run time. the first way that comes to mind doesn't actually get the height of them, it merely has 2 stored values per tile and you compare them before placing the new one.
if your not using a tile sheet, and some how generating the image of the terrain as it goes, then the way to get the height, is to check the value of each pixel on the far right column until you finds one that is non-transparent. and return the difference between there and the tiles pixel height.
the first would use more memory, but the second more time per tile placed.
Thanks for the help :) , currently i'm not working on this way, i found on assetstore a script that creates 2D terrains, so all my headache has gone :). But thanks for the help again. Obs: I tried the first method and worked when i did that, but now i'm using this scripts.
Nothing is better than make some search before start something :)
Your answer
Follow this Question
Related Questions
UI Button Sizing unit 0 Answers
NGUI sprite size 1 Answer
What Size To Make Art Assets? 1 Answer
Problems with importing image.png at its actual size and quality 2 Answers