|
@@ -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)
|
|
|
}
|
|
|
}
|
|
|
|