Dynamic height for isometric tile sprite


(Connery0) #1

Alright thanks to the code I found in a scale 9 class I solved the problem now

So here’s the code I use now https://gist.github.com/connery0/0abd09b1d81774022502#file-tile-as Together with this image http://i.imgur.com/kZGSIsZ.png I can now make tiles of diferent sizes, just by inputing the height in the constructor http://puu.sh/brSYs/8e6ded771b.png


Hello, I’m prety new to flashpunk, and still am figuring out most of it’s functions but I’m a bit confused by the ways to make sprites, I got how you can make animations or use rectangles to divide a single image into diferent sprites.

But I want to make a isometric game and I thought up a way to make tile height scale when I need it.

The idea would be to have a top and bottom part of a sprite and then (one or more types) of repeating pieces to put in between to make it match the neede height example: http://i.imgur.com/7m25j1s.png

But I can’t figure out how to do this in flashpunk.

I know this probably has a easy solution, but I realy can’t find it. (also do you use the help category for this? or is that specific to development of new functions? )


(Zachary Lewis) #2

You can create a class to do this that extends Graphic. You’d basically be creating a modified scale 9 image, but instead of scaling the image, you’d want to tile it.


(Connery0) #3

Alright I found a Scale 9 class on here and the setTo() seems like the function I’ll need,

So I’ll try messing around with that, thanks a lot

edit: I’m a idiot and setTo just changes the values of the point, but the examples of the copyPixels() are realy usefull, and I should be able to do it with those.

I will upload a finished version here once I get it to work


(Connery0) #4

Is there a way to get the classname from a object in flashpunk? in plain AS3 I was able to get what type a object was, and then just make a new class that was the same. I have been searching around google and the API but can’t find anything like it.

The reason I ask this is because when I want to change the height of a tile that’s already onscreen it acts a bit wierd. I fixed that by just creating a new tile each time I change the height but that won’t work if I want diferent kinds of tile (objects) This is a swf that replaces the tile http://puu.sh/btcFn/e6bd687fa4.swf (it uses this in the code http://puu.sh/btcFH/4c99d09bb6.png ) And this is what happens if I just try to change the size http://puu.sh/btcCz/294bb5c856.swf (code: http://puu.sh/btcDK/8d234d953f.png)

I’m honestly not sure where the problem is so I also uploaded it to github in case anybody has the time to look trough it https://github.com/connery0/tiletest

tiletest is the world I use.

tile entity is the actual tile

and tile is the image class that also has the code for the resizing