ソースを参照

more precise calculations for Tile ix/iy/iwidth/iheight

trethaller 6 年 前
コミット
e67a621d8a
1 ファイル変更4 行追加4 行削除
  1. 4 4
      h2d/Tile.hx

+ 4 - 4
h2d/Tile.hx

@@ -18,16 +18,16 @@ class Tile {
 	public var height(default,null) : Float;
 
 	public var ix(get,never) : Int;
-	function get_ix() return Std.int(x);
+	inline function get_ix() return Math.floor(x);
 
 	public var iy(get,never) : Int;
-	function get_iy() return Std.int(y);
+	inline function get_iy() return Math.floor(y);
 
 	public var iwidth(get,never) : Int;
-	function get_iwidth() return Std.int(width);
+	inline function get_iwidth() return Math.ceil(width + x) - ix;
 
 	public var iheight(get,never) : Int;
-	function get_iheight() return Std.int(height);
+	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;