12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import { _decorator, Component, EditBox, Vec2, Node } 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;
- @property(Node) btn_set:Node = 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()
- })
- this.btn_set.on(Node.EventType.TOUCH_END, ()=>{
-
- })
- }
- 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()
- }
- }
|