future vor 1 Jahr
Ursprung
Commit
27a643fabc

+ 2 - 2
assets/data/data.ts

@@ -62,8 +62,8 @@ export class ani_frame{ //动画帧
     public size_width:number = 100; //宽高
     public size_height:number = 100; 
     public rotation:number = 0; //旋转
-    public rotation_x:number = 0; //旋转x点
-    public rotation_y:number = 0; //旋转y点
+    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 = "";//资源

+ 27 - 27
assets/edit_game.scene

@@ -116,7 +116,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 960,
+      "x": 959.9999999999999,
       "y": 960,
       "z": 0
     },
@@ -206,8 +206,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 1920,
-      "height": 1920
+      "width": 1919.9999999999998,
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -344,7 +344,7 @@
     "_priority": 0,
     "_fov": 45,
     "_fovAxis": 0,
-    "_orthoHeight": 960,
+    "_orthoHeight": 959.9999999999999,
     "_near": 0,
     "_far": 1000,
     "_color": {
@@ -533,8 +533,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 840,
-      "height": 1920
+      "width": 839.9999999999997,
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -7333,7 +7333,7 @@
     "_lpos": {
       "__type__": "cc.Vec3",
       "x": 0,
-      "y": -510,
+      "y": -509.9999999999999,
       "z": 0
     },
     "_lrot": {
@@ -7390,7 +7390,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 420,
+      "x": 419.99999999999983,
       "y": 0,
       "z": 0
     },
@@ -7790,7 +7790,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 800,
+      "width": 799.9999999999997,
       "height": 860
     },
     "_anchorPoint": {
@@ -7908,7 +7908,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": -285,
+      "x": -284.99999999999983,
       "y": -105,
       "z": 0
     },
@@ -8191,7 +8191,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 800,
+      "width": 799.9999999999997,
       "height": 210
     },
     "_anchorPoint": {
@@ -8275,7 +8275,7 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 840,
+      "width": 839.9999999999997,
       "height": 900
     },
     "_anchorPoint": {
@@ -16616,8 +16616,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 840,
-      "height": 1920
+      "width": 839.9999999999997,
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -18508,7 +18508,7 @@
     "_prefab": null,
     "_lpos": {
       "__type__": "cc.Vec3",
-      "x": 750.1330000000002,
+      "x": 750.133,
       "y": 0,
       "z": 0
     },
@@ -172633,8 +172633,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 419.9999999999998,
-      "height": 1870
+      "width": 419.99999999999943,
+      "height": 1869.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -172858,8 +172858,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 419.9999999999998,
-      "height": 1920
+      "width": 419.99999999999943,
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -173267,8 +173267,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 1920,
-      "height": 1080
+      "width": 1919.9999999999998,
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -175072,8 +175072,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 1920,
-      "height": 1080
+      "width": 1919.9999999999998,
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -175163,8 +175163,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 1920,
-      "height": 1080
+      "width": 1919.9999999999998,
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -175476,8 +175476,8 @@
     "__prefab": null,
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 1920,
-      "height": 1920
+      "width": 1919.9999999999998,
+      "height": 1919.9999999999998
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",

Datei-Diff unterdrückt, da er zu groß ist
+ 478 - 126
assets/resources/prefab/add_animation.prefab


+ 14 - 3
assets/script/edit/animation/edit_animation.ts

@@ -6,12 +6,14 @@ import { Attributes } from '../Attributes';
 import { tools } from '../../tools';
 import { opt_frame } from './opt_frame';
 import { control } from '../control';
+import { gameManager } from '../../run/gameManager';
 const { ccclass, property } = _decorator;
 
 @ccclass('edit_animation')
 export class edit_animation extends Component {
     @property(Node) ani_sf:Node = null;
     @property(Node) btn_new_ani_frame:Node = null;
+    @property(Node) btn_save:Node = null;
     @property(Node) btn_run:Node = null;
     @property(Node) frame_content:Node  = null;
     @property(Prefab) item_prefab:Prefab = null;
@@ -56,6 +58,9 @@ export class edit_animation extends Component {
                 this.node.active = false;
             }
         })
+        this.btn_save.on(Node.EventType.TOUCH_END, ()=> {
+            gameManager.requestSaveEditScene()
+        })
         this.btn_run.on(Node.EventType.TOUCH_END,()=>{
             if(this.m_data.ani_frame_list.length<2){
                 return tools.showToast("动画不能低于2帧")
@@ -122,6 +127,8 @@ export class edit_animation extends Component {
             size:Size;
             pos:Vec3;
             rotation:number;
+            anchorPointX:number;
+            anchorPointY:number;
         }
         let bindTarget : BindTarget = new BindTarget();
         let rotation = up_frame.rotation == undefined?0:up_frame.rotation
@@ -130,14 +137,17 @@ export class edit_animation extends Component {
         bindTarget.opacity = up_frame.transparent;
         bindTarget.size = new Size(up_frame.size_width,up_frame.size_height)
         bindTarget.pos = new Vec3(up_frame.pos_x-origin_x,up_frame.pos_y-origin_y)
+        bindTarget.anchorPointX = up_frame.anchor_point_x
+        bindTarget.anchorPointY = up_frame.anchor_point_y
         let color_opactiy_tw_size = tween(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.ani_sf.getComponent(Sprite).color = tar.color; 
                 self.ani_sf.getComponent(UIOpacity).opacity = tar.opacity;
                 self.ani_sf.getComponent(UITransform).setContentSize(tar.size)
                 self.ani_sf.position = tar.pos
                 self.ani_sf.angle = tar.rotation;
+                self.ani_sf.getComponent(UITransform).setAnchorPoint(tar.anchorPointX, tar.anchorPointY)
             }
         }).call(()=>{
             call()
@@ -195,8 +205,9 @@ 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
-        // this.new_frame.getComponent(new_frame).show_edit(item,up_frame);
+        //  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);
+        console.log('item.getIndex()=',item.getIndex())
         let up_frame = null;
         if(item.getIndex()>=0) {
             up_frame = this.m_data.ani_frame_list[item.getIndex()]

+ 44 - 27
assets/script/edit/animation/new_frame.ts

@@ -25,8 +25,8 @@ 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) anchor_point_x:Node = null;
+    @property(Node) anchor_point_y:Node = null;
     @property(Node) btn_rotation_center:Node = null;
     @property(Node) hide_spr:Node = null;
 
@@ -61,7 +61,7 @@ export class new_frame extends Component {
                 // 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.setupInitAnchorPointXY()
                 this.setupSprRatationAction()
             })
         })
@@ -75,7 +75,7 @@ export class new_frame extends Component {
         })
 
         this.btn_rotation_center.on(Node.EventType.TOUCH_END, ()=> {
-            this.setupInitRotationX_Y()
+            this.setupInitAnchorPointXY()
         },this)
 
         this.next_time.on('editing-did-ended', this.change, this);
@@ -86,8 +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);
+        this.anchor_point_x.on('editing-did-ended', this.change, this);
+        this.anchor_point_y.on('editing-did-ended', this.change, this);
     }
 
     close(){
@@ -98,7 +98,9 @@ export class new_frame extends Component {
             this.m_item.setData(this.m_data)
         }
         if(this.m_edit_call!=null){
-            this.m_edit_call()
+            if(this.checkAnchorXY()) {
+                this.m_edit_call()
+            }
         }
     }
     create_frame(){
@@ -116,10 +118,12 @@ export class new_frame extends Component {
             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;
+            ani_frame_data.anchor_point_x = this.m_data.anchor_point_x;
+            ani_frame_data.anchor_point_y = this.m_data.anchor_point_y;
             console.log("ani_frame_data//",ani_frame_data)
-            this.m_create_call(ani_frame_data)
+            if(this.checkAnchorXY()) {
+                this.m_create_call(ani_frame_data)
+            }
         }
     }
 
@@ -201,31 +205,30 @@ 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.anchor_point_x==undefined) {
+            this.m_data.anchor_point_x = 0.5;
         }
-        if(this.m_data.rotation_y==undefined) {
-            this.m_data.rotation_y = 0;
+        if(this.m_data.anchor_point_y==undefined) {
+            this.m_data.anchor_point_y = 0.5;
         }
         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()
+            this.anchor_point_x.getComponent(EditBox).string =  this.m_data.anchor_point_x.toString()
+            this.anchor_point_y.getComponent(EditBox).string =  this.m_data.anchor_point_y.toString()
         } else {
-            this.setupInitRotationX_Y()
+            this.setupInitAnchorPointXY()
         }
-       
     }
 
     change(){
-        this.setupSprRatationAction()
         this.updateData()
+        this.setupSprRatationAction()
     }
 
     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.anchor_point_x = parseFloat(this.anchor_point_x.getComponent(EditBox).string)
+        this.m_data.anchor_point_y = parseFloat(this.anchor_point_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)
@@ -235,15 +238,29 @@ export class new_frame extends Component {
         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()
+    checkAnchorXY():boolean {
+        if(this.m_data.anchor_point_x<0||this.m_data.anchor_point_x>1) {
+            tools.showToast('锚点X应在0-1之间')
+            return false
+        }
+        if(this.m_data.anchor_point_y<0||this.m_data.anchor_point_y>1) {
+            tools.showToast('锚点Y应在0-1之间')
+            return false
+        }
+        return true
+    }
+
+    setupInitAnchorPointXY() {
+        this.m_data.anchor_point_x = 0.5
+        this.m_data.anchor_point_y = 0.5
+        this.anchor_point_x.getComponent(EditBox).string = this.m_data.anchor_point_x.toString()
+        this.anchor_point_y.getComponent(EditBox).string = this.m_data.anchor_point_y.toString()
+        this.hide_spr.getComponent(UITransform).setAnchorPoint(this.m_data.anchor_point_x, this.m_data.anchor_point_y)
     }
     
     setupSprRatationAction() {
-        this.hide_spr.angle = parseFloat(this.rotation.getComponent(EditBox).string)
+        this.hide_spr.angle = this.m_data.rotation
+        this.hide_spr.getComponent(UITransform).setAnchorPoint(this.m_data.anchor_point_x, this.m_data.anchor_point_y)
     }
 }
 

+ 3 - 1
assets/script/edit/animation/opt_frame.ts

@@ -1,9 +1,10 @@
-import { _decorator, Color, Component, Node, Sprite } from 'cc';
+import { _decorator, Color, Component, Label, Node, Sprite } from 'cc';
 import { frame_item } from './frame_item';
 const { ccclass, property } = _decorator;
 
 @ccclass('opt_frame')
 export class opt_frame extends Component {
+    @property(Node) lab_title:Node = null;
     @property(Node) btn_delete:Node = null;
     @property(Node) btn_edit:Node = null;
     @property(Node) btn_cancel:Node = null;
@@ -12,6 +13,7 @@ export class opt_frame extends Component {
     private m_item = null;
     public show(item:frame_item){
         this.m_item = item;
+        this.lab_title.getComponent(Label).string = '第' + item.getIndex() + '帧'
         this.node.active = true;
     }
 

+ 2 - 18
assets/script/edit/edit_scene.ts

@@ -10,6 +10,7 @@ import { cur_edit_scene } from './cur_edit_scene';
 import { scene_task } from './task/scene_task';
 import { http } from '../http';
 import { Attributes } from './Attributes';
+import { gameManager } from '../run/gameManager';
 const { ccclass, property } = _decorator;
 
 @ccclass('edit_scene')
@@ -78,24 +79,7 @@ export class edit_scene extends Component {
             tools.game_run_all()
         })
         this.btn_save.on(Node.EventType.TOUCH_END,()=>{
-            tools.show_loading(()=>{
-                // let data = new FormData()
-                let content = control.Singleton.get_bag_data().content
-                let zujian_id = config.last_id;
-                let id = control.Singleton.get_bag_data().id;
-                // data.append("content",JSON.stringify(content))
-                // data.append("zujian_id",zujian_id+"")
-                // data.append("id",id+"")
-
-                console.log("btn_save",content)
-            
-                http.post("/tool/mysnote/save",  {"content":JSON.stringify(content),"zujian_id":zujian_id,"id":id},(err,data)=>{
-                    if(!err){
-                        tools.showToast("保存成功!")
-                    }
-                    tools.hide_loading()
-                })
-            })
+            gameManager.requestSaveEditScene()
         })
         this.btn_delete.on(Node.EventType.TOUCH_END,()=>{
             if(this.m_main.control_view.get_bag_data().content.length<=0){

+ 21 - 0
assets/script/run/gameManager.ts

@@ -535,6 +535,27 @@ export class gameManager extends Component {
     public getCurSceneIndex(){
         return this.mCurSceneIndex;
     }
+
+    //保存编辑场景
+    public static requestSaveEditScene() {
+        tools.show_loading(()=>{
+            // let data = new FormData()
+            let content = control.Singleton.get_bag_data().content
+            let zujian_id = config.last_id;
+            let id = control.Singleton.get_bag_data().id;
+            // data.append("content",JSON.stringify(content))
+            // data.append("zujian_id",zujian_id+"")
+            // data.append("id",id+"")
+            console.log("btn_save",content)
+            let request_data = {"content":JSON.stringify(content),"zujian_id":zujian_id,"id":id}
+            http.post("/tool/mysnote/save",  request_data, (err,data)=>{
+                if(!err){
+                    tools.showToast("保存成功!")
+                }
+                tools.hide_loading()
+            })
+        })
+    }
 }
 
 

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.