future 1 жил өмнө
parent
commit
c755c9640c

+ 3 - 1
assets/data/data.ts

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

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 1671 - 135
assets/resources/prefab/add_animation.prefab


+ 7 - 1
assets/script/edit/animation/edit_animation.ts

@@ -195,7 +195,12 @@ export class edit_animation extends Component {
     }
 
     onClickEdit(item:frame_item){
-        let up_frame = item.getIndex()>0?this.m_data.ani_frame_list[item.getIndex()-1]:null
+        // let up_frame = item.getIndex()>0?this.m_data.ani_frame_list[item.getIndex()-1]:null
+        // this.new_frame.getComponent(new_frame).show_edit(item,up_frame);
+        let up_frame = null;
+        if(item.getIndex()>=0) {
+            up_frame = this.m_data.ani_frame_list[item.getIndex()]
+        }
         this.new_frame.getComponent(new_frame).show_edit(item,up_frame);
     }
 
@@ -227,6 +232,7 @@ export class edit_animation extends Component {
     }
 
     onCreateFrame(frame:ani_frame){
+        console.log('this.m_data.ani_frame_list=',this.m_data.ani_frame_list)
         this.addFrameOnList(frame,this.m_data.ani_frame_list.length)
         this.m_data.ani_frame_list.push(frame)
         this.updateFirstFrameStatus()

+ 56 - 6
assets/script/edit/animation/new_frame.ts

@@ -25,7 +25,11 @@ export class new_frame extends Component {
     @property(Node) btn_origin_res:Node = null;
 
     @property(Node) rotation:Node = null;
+    @property(Node) rotation_x:Node = null;
+    @property(Node) rotation_y:Node = null;
+    @property(Node) btn_rotation_center:Node = null;
     @property(Node) hide_spr:Node = null;
+
     private m_up_frame:ani_frame = null;
     private m_create_call = null;
     private m_edit_call = null;
@@ -54,8 +58,11 @@ export class new_frame extends Component {
             tools.select_res_list((data:bag_item_data)=>{
                 this.m_data.url = data.url;
                 this.m_data.url_name = data.name;
-                this.btn_select_res.getComponent(Sprite).spriteFrame = control.res_map.get(this.m_data.url_name)
-                this.hide_spr.getComponent(Sprite).spriteFrame = this.btn_select_res.getComponent(Sprite).spriteFrame
+                // this.btn_select_res.getComponent(Sprite).spriteFrame = control.res_map.get(this.m_data.url_name)
+                // this.hide_spr.getComponent(Sprite).spriteFrame = this.btn_select_res.getComponent(Sprite).spriteFrame
+                this.hide_spr.getComponent(Sprite).spriteFrame = control.res_map.get(this.m_data.url_name)
+                this.setupInitRotationX_Y()
+                this.setupSprRatationAction()
             })
         })
 
@@ -67,6 +74,10 @@ export class new_frame extends Component {
             this.size_height.getComponent(EditBox).string =  this.m_data.size_height.toString()
         })
 
+        this.btn_rotation_center.on(Node.EventType.TOUCH_END, ()=> {
+            this.setupInitRotationX_Y()
+        },this)
+
         this.next_time.on('editing-did-ended', this.change, this);
         this.pos_x.on('editing-did-ended', this.change, this);
         this.pos_y.on('editing-did-ended', this.change, this);
@@ -75,6 +86,8 @@ export class new_frame extends Component {
         this.color.on('editing-did-ended', this.change, this);
         this.transparent.on('editing-did-ended', this.change, this);
         this.rotation.on('editing-did-ended', this.change, this);
+        this.rotation_x.on('editing-did-ended', this.change, this);
+        this.rotation_y.on('editing-did-ended', this.change, this);
     }
 
     close(){
@@ -102,12 +115,16 @@ export class new_frame extends Component {
             ani_frame_data.url = this.m_data.url;
             ani_frame_data.url_name = this.m_data.url_name;
             ani_frame_data.rotation = this.m_data.rotation;
+            // console.log('x=',this.m_data.rotation_x, 'y=',this.m_data.rotation_y)
+            ani_frame_data.rotation_x = this.m_data.rotation_x;
+            ani_frame_data.rotation_y = this.m_data.rotation_y;
             console.log("ani_frame_data//",ani_frame_data)
             this.m_create_call(ani_frame_data)
         }
     }
 
     public show(up_frame:ani_frame=null){
+        console.log("show show show show show")
         this.edit_status = false;
         this.m_up_frame = up_frame;
         this.node.active = true;
@@ -120,8 +137,12 @@ export class new_frame extends Component {
                 url = this.m_up_frame.url;
             }
         }
+        // if(url_name.length>0){
+        //     this.btn_select_res.getComponent(Sprite).spriteFrame = control.res_map.get(url_name)
+        // }
+        // this.hide_spr.getComponent(Sprite).spriteFrame = this.btn_select_res.getComponent(Sprite).spriteFrame
         if(url_name.length>0){
-            this.btn_select_res.getComponent(Sprite).spriteFrame = control.res_map.get(url_name)
+            this.hide_spr.getComponent(Sprite).spriteFrame = control.res_map.get(url_name)
         }
         let x = up_frame?up_frame.pos_x: Math.floor(att.x);
         let y = up_frame?up_frame.pos_y: Math.floor(att.y);
@@ -140,13 +161,13 @@ export class new_frame extends Component {
             }
         }
         this.m_data.rotation =   up_frame?up_frame.rotation:0;
-        this.hide_spr.getComponent(Sprite).spriteFrame = this.btn_select_res.getComponent(Sprite).spriteFrame
         this.lab_origin_pos.getComponent(Label).string = `(x:${Math.floor(att.x)},y:${Math.floor(att.y)})`
         this.lab_origin_size.getComponent(Label).string = `(w:${att.width},h:${att.height})`
         this.initAtt()
     }
 
     public show_edit(item:frame_item,up_frame:ani_frame=null){
+        console.log("show_edit show_edit show_edit show_edit show_edit")
         this.m_up_frame = up_frame;
         this.node.active = true;
         this.m_data = item.getData();
@@ -162,9 +183,11 @@ export class new_frame extends Component {
             }    
         }
         this.edit_status = true;
-        this.btn_select_res.getComponent(Sprite).spriteFrame = control.res_map.get(this.m_data.url_name)
-        this.hide_spr.getComponent(Sprite).spriteFrame = this.btn_select_res.getComponent(Sprite).spriteFrame
+        // this.btn_select_res.getComponent(Sprite).spriteFrame = control.res_map.get(this.m_data.url_name)
+        // this.hide_spr.getComponent(Sprite).spriteFrame = this.btn_select_res.getComponent(Sprite).spriteFrame
+        this.hide_spr.getComponent(Sprite).spriteFrame = control.res_map.get(this.m_data.url_name)
         this.initAtt()
+        this.setupSprRatationAction()
     }
 
     initAtt(){
@@ -178,15 +201,31 @@ export class new_frame extends Component {
         if(this.m_data.rotation==undefined){
             this.m_data.rotation = 0;
         }
+        if(this.m_data.rotation_x==undefined) {
+            this.m_data.rotation_x = 0;
+        }
+        if(this.m_data.rotation_y==undefined) {
+            this.m_data.rotation_y = 0;
+        }
         this.rotation.getComponent(EditBox).string =  this.m_data.rotation.toString()
+        if(this.edit_status) {
+            this.rotation_x.getComponent(EditBox).string =  this.m_data.rotation_x.toString()
+            this.rotation_y.getComponent(EditBox).string =  this.m_data.rotation_y.toString()
+        } else {
+            this.setupInitRotationX_Y()
+        }
+       
     }
 
     change(){
+        this.setupSprRatationAction()
         this.updateData()
     }
 
     updateData(){
         this.m_data.rotation =  parseFloat(this.rotation.getComponent(EditBox).string) 
+        this.m_data.rotation_x = parseFloat(this.rotation_x.getComponent(EditBox).string)
+        this.m_data.rotation_y = parseFloat(this.rotation_y.getComponent(EditBox).string)
         this.m_data.next_time =  parseFloat(this.next_time.getComponent(EditBox).string) 
         this.m_data.pos_x = parseInt(this.pos_x.getComponent(EditBox).string)
         this.m_data.pos_y = parseInt(this.pos_y.getComponent(EditBox).string)
@@ -195,6 +234,17 @@ export class new_frame extends Component {
         this.m_data.color = this.color.getComponent(EditBox).string
         this.m_data.transparent = parseInt(this.transparent.getComponent(EditBox).string)
     }
+
+    setupInitRotationX_Y() {
+        this.m_data.rotation_x = this.m_data.size_width / 2
+        this.m_data.rotation_y = this.m_data.size_height / 2
+        this.rotation_x.getComponent(EditBox).string = this.m_data.rotation_x.toString()
+        this.rotation_y.getComponent(EditBox).string = this.m_data.rotation_y.toString()
+    }
+    
+    setupSprRatationAction() {
+        this.hide_spr.angle = parseFloat(this.rotation.getComponent(EditBox).string)
+    }
 }
 
 

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно