123456789101112131415161718192021222324252627282930313233343536373839 |
- 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()
- }
- }
|