You need to compute the final position by yourself like @maitag suggested.
But be careful I think there is some bug when you use rotation after scaling or vice versa with specific values. Anybody has the same bug?
You need to compute the final position by yourself like @maitag suggested.
But be careful I think there is some bug when you use rotation after scaling or vice versa with specific values. Anybody has the same bug?
Currently tile.matrix
is what the renderer uses, the get/set x
, y
, rotation
(etc) are really convenience methods over the matrix, but as you know, the order of scale vs rotation affects this.
We donât support a center or offset on tilesets, but perhaps for ergonomics, we need to. I wanted to avoid doing matrix math like this in the tile render, but perhaps this is important to usability
What do you mean? That my issue is not a bug? So how can I use negative scale for example? Should I only use matrix instead of get x,y,rotation and scale?
Thatâs what I do:
// rotation : Float
// scale : Float
// positionX : Float
// positionY : Float
// pivotX : Float
// pivotY : Float
var mat = tile.matrix;
mat.a = Math.cos(rotation) * scale;
mat.c = Math.sin(rotation) * scale;
mat.b = - mat.c;
mat.d = mat.a;
// set matrix **before** setting x and y, because they are setters, and they set
// internal flag __transformDirty
tile.x = positionX - pivotX * mat.a - pivotY * mat.c;
tile.y = positionY - pivotX * mat.b - pivotY * mat.d;
It seems that Matrix
has method setRotation(theta : Float, scale : Float)
, but unfortunately it is private
@singmajesty It seems that tile.visible
doesnât work for neko, cpp and webgl.
Example (webgl) - http://pub.zame-dev.org/tmp/bunnymark-tilemap-visibility/
(click left mouse button to toggle first bunny visibility).
Source - https://gist.github.com/restorer/c160c1b844f4642c1bbd9e8c7aa2c89b
(basically same as BunnyMark, but instead of adding bunnies it toggle visibility)
When tile is not visible, tile position is not updated, but tile still visible.
Thank you!
It should be fixed in the latest commit now on GIT
Using the latest GIT commit for the visibility fix of tiles, it seems that it doesnât fix for Android output. The tiles I turn visibility off for donât come back after I make them visible again.
Would the possibility of isometric support be a silly idea?
What do you mean? Isometric is just a matter of position and z-orderâŚitâs up to you!
Indeed, it is! Thatâs why I thought of the possibility of adding a flag to Tilemap for handling such things out of the box.
Could you try OpenFL 4.2 and Lime 3.2, and see if it resolves it? If I remember, there were a few different commits that amounted to fixing tile.visible
Could this be used to restore the functionality of Tilesheet class?
Tilemap
can do much of the work of the old Tilesheet
class, but without the same bugs, and with better performance. There are a few key differences (Tilemap
preserves state between renders, is âpassiveâ not âactiveâ in rendering and is a DisplayObject
) but should otherwise should do the job
And how to apply color transformation now? (Previous Tilesheet.TILE_RGB)
This feature doesnât exist yet.
Any hints how to apply colour transformation for now?
If you want to change the color of a whole Tilemap
object I think itâs possible actually by using tilemap.filter = [new ShaderFilter(yourShaderToChangeColor)]
.
For individual Tiles
, there is no way to achieve that except by rewriting the GLTilemap
(add support for custom shader attributes) and Tiles
(add color attribute) classes and use your own Shader.
I would be interested to have such feature but for now I donât have the time to write it myself.
Care to share a code example, please?
To tint, just try tilemap.filter = [ new ColorMatrixFilter (matrix) ]
http://api.openfl.org/openfl/filters/ColorMatrixFilter.html
http://www.emanueleferonato.com/2009/04/28/understanding-as3-colormatrixfilter-class/
Thanks @singmajesty!
I just hope some method of manipulating separate Tiles will be possible to implement soon!