future hai 1 ano
pai
achega
3a96715b19

+ 2 - 0
assets/data/data.ts

@@ -14,6 +14,8 @@ export class attributes_data{
     public z:number = 0;
     public width:number = 0;
     public height:number = 0;
+    public anchor_x:number = 0.5;
+    public anchor_y:number = 0.5;
     public rotation:number = 0;
     public src:string = "";
     public src_name:string = "";

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1354 - 149
assets/edit_game.scene


+ 1 - 0
assets/script/config.ts

@@ -190,6 +190,7 @@ export class config {
         scene_rule_tips:"scene_rule_tips",
         remark:"remark",
         rotation:"rotation",
+        anchor:"anchor",
     }
 
     static last_id:number = 0;

+ 22 - 0
assets/script/edit/Attributes.ts

@@ -26,6 +26,7 @@ import { attributes_show } from './attributes/attributes_show';
 import { attributes_scene_setting } from './attributes/attributes_scene_setting';
 import { attributes_remark } from './attributes/attributes_remark';
 import { attributes_rotation } from './attributes/attributes_rotation';
+import { attributes_anchor } from './attributes/attributes_anchor';
 const { ccclass, property } = _decorator;
 
 @ccclass('Attributes')
@@ -35,6 +36,7 @@ export class Attributes extends Component {
     @property(Node) attributes_remark:Node = null;
     @property(Node) attributes_x_y:Node = null;
     @property(Node) attributes_w_h:Node = null;
+    @property(Node) attributes_anchor:Node = null;
     @property(Node) attributes_rotation:Node = null;
     @property(Node) attributes_res:Node = null;
     @property(Node) attributes_origin:Node = null;
@@ -66,6 +68,7 @@ export class Attributes extends Component {
         this.attributes_map.set("remark",this.attributes_remark)
         this.attributes_map.set("pos",this.attributes_x_y)
         this.attributes_map.set("size",this.attributes_w_h)
+        this.attributes_map.set("anchor",this.attributes_anchor)
         this.attributes_map.set("rotation",this.attributes_rotation)
         this.attributes_map.set("url",this.attributes_res)
         this.attributes_map.set("origin",this.attributes_origin)
@@ -104,6 +107,7 @@ export class Attributes extends Component {
         this.attributes_w_h.getComponent(attributes_w_h).initView(this.onChangeSize.bind(this))
         this.attributes_x_y.getComponent(attributes_x_y).initView(this.onChangePos.bind(this))
         this.attributes_rotation.getComponent(attributes_rotation).initView(this.onChangeRotation.bind(this))
+        this.attributes_anchor.getComponent(attributes_anchor).initView(this.onChangeAnchor.bind(this))
         this.attributes_origin.getComponent(attributes_origin).initView(this.onChangeOrigin.bind(this))
         this.hideAllAtt()
     }
@@ -113,6 +117,12 @@ export class Attributes extends Component {
         ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.remark)
     }
 
+    onChangeAnchor(anchor:Vec2){
+       this.cur_att_data.anchor_x = anchor.x
+       this.cur_att_data.anchor_y = anchor.y
+       ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.anchor)
+    }
+
     onChangeRotation(rotation: number) {
         this.cur_att_data.rotation = rotation
         ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.rotation)
@@ -234,6 +244,7 @@ export class Attributes extends Component {
                 this.attributes_map.get("text_sound").active = false;
                 this.attributes_map.get("count_down").active = false;
                 this.attributes_map.get("z_index").active = false;
+                this.attributes_map.get("anchor").active = true;
                 this.attributes_map.get("rotation").active = true;
                 if(data.widget_type===config.Widget_Type_List.DRAG_TYPE){
                     this.attributes_map.get("drop").active = true;
@@ -257,6 +268,7 @@ export class Attributes extends Component {
                     this.attributes_map.get("pos").active = false;
                     this.attributes_map.get("size").active = false;
                     this.attributes_map.get("text_sound").active = true;
+                    this.attributes_map.get("anchor").active = false;
                     this.attributes_map.get("rotation").active = false;
                 }else if(data.widget_type===config.Widget_Type_List.QUESTION_SELECT){
                     this.attributes_map.get("animation").active = false;
@@ -266,6 +278,7 @@ export class Attributes extends Component {
                     this.attributes_map.get("size").active = false;
                     this.attributes_map.get("pos").active = true;
                     this.attributes_map.get("question_select").active = true;
+                    this.attributes_map.get("anchor").active = false;
                     this.attributes_map.get("rotation").active = false;
                 }else if(data.widget_type===config.Widget_Type_List.COUNT_DOWN){
                     this.attributes_map.get("animation").active = false;
@@ -274,6 +287,7 @@ export class Attributes extends Component {
                     this.attributes_map.get("pos").active = true;
                     this.attributes_map.get("size").active = false;
                     this.attributes_map.get("count_down").active = true;
+                    this.attributes_map.get("anchor").active = false;
                     this.attributes_map.get("rotation").active = false;
                 }
             }else if(data.type===config.attributes_type.scene){
@@ -284,6 +298,7 @@ export class Attributes extends Component {
                 this.attributes_map.get("url").active = true;
                 this.attributes_map.get("animation").active = true;
                 this.attributes_map.get("scene_set").active = true;
+                this.attributes_map.get("anchor").active = false;
                 this.attributes_map.get("rotation").active = false;
                 this.attributes_map.get("be_active").active = true;
             }
@@ -310,6 +325,9 @@ export class Attributes extends Component {
             let size = this.getSizeCom()
             size.update_att(this.cur_att_data.width,this.cur_att_data.height)
 
+            let anchor = this.getAnchorCom()
+            anchor.update_att(this.cur_att_data.anchor_x, this.cur_att_data.anchor_y)
+
             let rotation = this.getRotationCom()
             rotation.update_att(this.cur_att_data.rotation)
 
@@ -424,6 +442,10 @@ export class Attributes extends Component {
         return this.attributes_map.get("size").getComponent(attributes_w_h);
     }
 
+    getAnchorCom() {
+        return this.attributes_map.get("anchor").getComponent(attributes_anchor);
+    }
+
     getRotationCom(){
         return this.attributes_map.get("rotation").getComponent(attributes_rotation);
     }

+ 39 - 0
assets/script/edit/attributes/attributes_anchor.ts

@@ -0,0 +1,39 @@
+import { _decorator, Component, EditBox, Vec2 } from 'cc';
+const { ccclass, property } = _decorator;
+
+@ccclass('attributes_anchor')
+export class attributes_anchor extends Component {
+    @property(EditBox) editBox_x:EditBox = null;
+    @property(EditBox) editBox_y:EditBox = null;
+    private call_back:Function = null;
+    start() {
+        this.editBox_x.node.on(EditBox.EventType.EDITING_DID_ENDED, ()=>{
+            this.change()
+        })
+        this.editBox_y.node.on(EditBox.EventType.EDITING_DID_ENDED, ()=>{
+            this.change()
+        })
+    }
+
+    initView(call:Function){
+        this.call_back = call
+    }
+
+    change(){
+        if(this.call_back!=null){
+            this.call_back(new Vec2(parseFloat(this.editBox_x.string),parseFloat(this.editBox_y.string)))
+        }
+    }
+
+    update_att(x:number, y:number) {
+        if(x==undefined||x==null) {
+            x = 0.5
+        }
+        if(y==undefined||y==null) {
+            y = 0.5
+        }
+        this.editBox_x.string = x.toString()
+        this.editBox_y.string = y.toString()
+    }
+}
+

+ 9 - 0
assets/script/edit/attributes/attributes_anchor.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "4.0.23",
+  "importer": "typescript",
+  "imported": true,
+  "uuid": "6ed4f316-f354-4676-9df7-3860ce7a131e",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

+ 6 - 1
assets/script/edit/scroll_scene.ts

@@ -1,4 +1,4 @@
-import { _decorator, assetManager, Component, ImageAsset, Node, ScrollView, Size, Sprite, SpriteFrame, Texture2D, Toggle, UITransform } from 'cc';
+import { _decorator, assetManager, Component, ImageAsset, Node, ScrollView, Size, Sprite, SpriteFrame, Texture2D, Toggle, UITransform, Vec2 } from 'cc';
 import { attributes_data, scene_item_data } from '../../data/data';
 import { config } from '../config';
 import { ClientEvent } from '../clientEvent';
@@ -37,6 +37,11 @@ export class scroll_scene extends Component {
                     this.m_att.height = data.height;
                     this.getBg().getComponent(UITransform).contentSize = new Size(data.width,data.height)
                     break;
+                case config.attributes_list_type.anchor:
+                    this.m_att.anchor_x = data.anchor_x;
+                    this.m_att.anchor_y = data.anchor_y;
+                    this.getBg().getComponent(UITransform).setAnchorPoint(data.anchor_x, data.anchor_y)
+                    break;
                 case config.attributes_list_type.rotation:
                     this.m_att.rotation = data.rotation;
                     this.getBg().angle = data.rotation;

+ 7 - 0
assets/script/edit/widget_item.ts

@@ -365,6 +365,11 @@ export class widget_item extends Component {
                     this.spr.getComponent(UITransform).contentSize = new Size(data.width,data.height)
                     this.node.getComponent(UITransform).contentSize  = this.spr.getComponent(UITransform).contentSize
                     break;
+                case config.attributes_list_type.anchor:
+                    this.m_att.anchor_x = data.anchor_x;
+                    this.m_att.anchor_y = data.anchor_y;
+                    this.spr.getComponent(UITransform).setAnchorPoint(data.anchor_x, data.anchor_y)
+                    break;
                 case config.attributes_list_type.rotation:
                     this.m_att.rotation = data.rotation;
                     this.spr.angle = data.rotation;
@@ -552,6 +557,8 @@ export class widget_item extends Component {
         this.m_att.remark = this.m_att.remark;
         this.m_att.height = this.spr.getComponent(UITransform).contentSize.height;
         this.m_att.width = this.spr.getComponent(UITransform).contentSize.width;
+        this.m_att.anchor_x = this.m_data.att.anchor_x
+        this.m_att.anchor_y = this.m_data.att.anchor_y
         this.m_att.rotation = this.m_att.rotation;
         this.m_att.x = this.node.position.x;
         this.m_att.widget_type = this.m_data.type;

+ 11 - 0
assets/script/run/widget/widget_base.ts

@@ -31,6 +31,17 @@ export class widget_base extends Component {
         this.mData = data;
         this.icon.getComponent(UITransform).contentSize = new Size(this.mData.att.width,this.mData.att.height)
         this.icon.position = new Vec3(this.mData.att.x,this.mData.att.y)
+        
+        var anchor_x = 0.5
+        if(this.mData.att.anchor_x!=undefined&&this.mData.att.anchor_x!=null) {
+            anchor_x = this.mData.att.anchor_x
+        } 
+        var anchor_y = 0.5
+        if(this.mData.att.anchor_x!=undefined&&this.mData.att.anchor_x!=null) {
+            anchor_y = this.mData.att.anchor_y
+        }
+        this.icon.getComponent(UITransform).setAnchorPoint(anchor_x, anchor_y)
+
         if(this.mData.att.rotation==undefined||this.mData.att.rotation==null) {
             this.icon.angle = 0
         } else {

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio