|
@@ -13,6 +13,9 @@ class ObjectFollower extends Object {
|
|
|
public var offsetY = 0.;
|
|
|
public var offsetZ = 0.;
|
|
|
|
|
|
+ public var horizontalAlign : h2d.Flow.FlowAlign = Left;
|
|
|
+ public var verticalAlign : h2d.Flow.FlowAlign = Top;
|
|
|
+
|
|
|
public function new( obj, ?parent ) {
|
|
|
super(parent);
|
|
|
this.follow = obj;
|
|
@@ -28,11 +31,35 @@ class ObjectFollower extends Object {
|
|
|
var width = s2d == null ? h3d.Engine.getCurrent().width : s2d.width;
|
|
|
var height = s2d == null ? h3d.Engine.getCurrent().height : s2d.height;
|
|
|
var absPos = follow.getAbsPos();
|
|
|
- var p = scene.camera.project(absPos._41 + offsetX, absPos._42 + offsetY, absPos._43 + offsetZ, width, height, pixelSnap);
|
|
|
+ var p = scene.camera.project(absPos._41 + offsetX, absPos._42 + offsetY, absPos._43 + offsetZ, width, height);
|
|
|
x = p.x;
|
|
|
y = p.y;
|
|
|
visible = p.z > 0;
|
|
|
|
|
|
+ if( horizontalAlign != Left || verticalAlign != Top ) {
|
|
|
+ var prev = follow;
|
|
|
+ follow = null;
|
|
|
+ var b = getBounds(this); // prevent recursive
|
|
|
+ follow = prev;
|
|
|
+
|
|
|
+ var w = b.width, h = b.height;
|
|
|
+ switch( horizontalAlign ) {
|
|
|
+ case Middle: x -= w * 0.5;
|
|
|
+ case Right: x -= w;
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ switch( verticalAlign ) {
|
|
|
+ case Middle: y -= h * 0.5;
|
|
|
+ case Bottom: y -= h;
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if( pixelSnap ) {
|
|
|
+ x = Math.round(x);
|
|
|
+ y = Math.round(y);
|
|
|
+ }
|
|
|
+
|
|
|
if(followVisibility) {
|
|
|
var parent = follow;
|
|
|
while(parent != null) {
|