future 1 年間 前
コミット
e5fba63fa2

+ 2 - 0
assets/data/data.ts

@@ -61,6 +61,8 @@ export class ani_frame{ //动画帧
     public size_width:number = 100; //宽高
     public size_height:number = 100; 
     public rotation:number = 0; //旋转 
+    public anchor_point_x:number = 0.5; //锚点x
+    public anchor_point_y:number = 0.5; //锚点y
     public color:string = "#FFFFFF"; //颜色
     public transparent:number = 255; //透明度
     public url:string = "";//资源

+ 7 - 2
assets/script/run/scene_page.ts

@@ -13,6 +13,8 @@ class BindTarget{
     size:Size;
     pos:Vec3;
     rotation:number;
+    anchorPointX:number;
+    anchorPointY:number;
 }
 @ccclass('scene_page')
 export class scene_page extends Component {
@@ -223,15 +225,18 @@ export class scene_page extends Component {
         this.bindTarget.opacity = up_frame.transparent;
         this.bindTarget.size = new Size(up_frame.size_width,up_frame.size_height)
         this.bindTarget.pos = new Vec3(up_frame.pos_x,up_frame.pos_y)
-   
+        this.bindTarget.anchorPointX = up_frame.anchor_point_x==undefined?0.5:up_frame.anchor_point_x
+        this.bindTarget.anchorPointY = up_frame.anchor_point_y==undefined?0.5:up_frame.anchor_point_y
+
         let color_opactiy_tw_size = tween(this.bindTarget)
-        .to( tweenDuration, { pos:n_pos,color: _color,opacity:frame.transparent,size:new Size(frame.size_width,frame.size_height),rotation:frame.rotation }, {
+        .to( tweenDuration, { pos:n_pos,color: _color,opacity:frame.transparent,size:new Size(frame.size_width,frame.size_height),rotation:frame.rotation, anchorPointX:frame.anchor_point_x, anchorPointY:frame.anchor_point_y }, {
             onUpdate(tar:BindTarget){
                 self.content.getComponent(Sprite).color = tar.color; 
                 self.content.getComponent(UIOpacity).opacity = tar.opacity;
                 // self.content.getComponent(UITransform).setContentSize(tar.size)
                 self.content.position = tar.pos
                 self.content.angle = tar.rotation;
+                self.content.getComponent(UITransform).setAnchorPoint(tar.anchorPointX, tar.anchorPointY)
             }
         }).call(()=>{
             call()

+ 6 - 1
assets/script/run/widget/widget_base.ts

@@ -11,6 +11,8 @@ class BindTarget{
     size:Size;
     pos:Vec3;
     rotation:number;
+    anchorPointX:number;
+    anchorPointY:number;
 }
 @ccclass('widget_base')
 export class widget_base extends Component {
@@ -205,13 +207,16 @@ export class widget_base extends Component {
         this.bindTarget.opacity = up_frame.transparent;
         this.bindTarget.size = new Size(up_frame.size_width,up_frame.size_height)
         this.bindTarget.pos = new Vec3(up_frame.pos_x,up_frame.pos_y)
+        this.bindTarget.anchorPointX = up_frame.anchor_point_x==undefined?0.5:up_frame.anchor_point_x
+        this.bindTarget.anchorPointY = up_frame.anchor_point_y==undefined?0.5:up_frame.anchor_point_y
    
         let color_opactiy_tw_size = tween(this.bindTarget)
-        .to( tweenDuration, { pos:n_pos,color: _color,opacity:frame.transparent,size:new Size(frame.size_width,frame.size_height),rotation:frame.rotation }, {
+        .to( tweenDuration, { pos:n_pos,color: _color,opacity:frame.transparent,size:new Size(frame.size_width,frame.size_height),rotation:frame.rotation, anchorPointX:frame.anchor_point_x, anchorPointY:frame.anchor_point_y }, {
             onUpdate(tar:BindTarget){
                 self.icon.getComponent(Sprite).color = tar.color; 
                 self.icon.getComponent(UIOpacity).opacity = tar.opacity;
                 self.icon.getComponent(UITransform).setContentSize(tar.size)
+                self.icon.getComponent(UITransform).setAnchorPoint(tar.anchorPointX, tar.anchorPointY)
                 if(self.mCurAnimation.isMove){
                     self.node.position = tar.pos
                 }