Browse Source

added colorAdd auto-shader

ncannasse 11 năm trước cách đây
mục cha
commit
350365de2f
1 tập tin đã thay đổi với 23 bổ sung0 xóa
  1. 23 0
      h2d/Drawable.hx

+ 23 - 0
h2d/Drawable.hx

@@ -9,6 +9,7 @@ class Drawable extends Sprite {
 	public var tileWrap : Bool;
 	public var colorKey(default, set) : Null<Int>;
 	public var colorMatrix(get, set) : Null<h3d.Matrix>;
+	public var colorAdd(get, set) : Null<h3d.Vector>;
 
 	var shaders : hxsl.ShaderList;
 
@@ -18,6 +19,28 @@ class Drawable extends Sprite {
 		color = new h3d.Vector(1, 1, 1, 1);
 	}
 
+
+	function get_colorAdd() {
+		var s = getShader(h3d.shader.ColorAdd);
+		return s == null ? null : s.color;
+	}
+
+	function set_colorAdd( c : h3d.Vector ) {
+		var s = getShader(h3d.shader.ColorAdd);
+		if( s == null ) {
+			if( c != null ) {
+				s = addShader(new h3d.shader.ColorAdd());
+				s.color = c;
+			}
+		} else {
+			if( c == null )
+				removeShader(s);
+			else
+				s.color = c;
+		}
+		return c;
+	}
+
 	function set_colorKey(v:Null<Int>) {
 		var s = getShader(h3d.shader.ColorKey);
 		if( s == null ) {