浏览代码

Merge pull request #1 from trethaller/feature_float_tile

add ix, iy, iwidth, iheight accessors for backwards compat
Pavel Alexandrov 6 年之前
父节点
当前提交
3c1d949350
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      h2d/Tile.hx

+ 12 - 0
h2d/Tile.hx

@@ -17,6 +17,18 @@ class Tile {
 	public var width(default,null) : Float;
 	public var height(default,null) : Float;
 
+	public var ix(get,never) : Int;
+	inline function get_ix() return Math.floor(x);
+
+	public var iy(get,never) : Int;
+	inline function get_iy() return Math.floor(y);
+
+	public var iwidth(get,never) : Int;
+	inline function get_iwidth() return Math.ceil(width + x) - ix;
+
+	public var iheight(get,never) : Int;
+	inline function get_iheight() return Std.ceil(height + y) - iy;
+
 	function new(tex : h3d.mat.Texture, x : Float, y : Float, w : Float, h : Float, dx : Float=0, dy : Float=0) {
 		this.innerTex = tex;
 		this.x = x;