import { _decorator, Component, EditBox, Node, Vec2, Vec3 } from 'cc'; import { slider_widget } from './slider_widget'; const { ccclass, property } = _decorator; @ccclass('attributes_x_y') export class attributes_x_y extends Component { @property(EditBox) edit_x:EditBox = null; @property(EditBox) edit_y:EditBox = null; @property(EditBox) edit_z:EditBox = null; @property(Node) slider_x:Node = null; @property(Node) slider_y:Node = null; private _x:number = 0; private _y:number = 0; private call_back = null; private slider_status:boolean = false; public update_att(x:number,y:number,z:number){ this.edit_x.string = x.toString() this.edit_y.string = y.toString() this.edit_z.string = z.toString() this._x = x; this._y = y; } protected start(): void { this.edit_x.node.on('editing-did-ended', this.change, this); this.edit_y.node.on('editing-did-ended', this.change, this); this.edit_z.node.on('editing-did-ended', this.change, this); } public initView(call){ this.call_back = call; this.slider_x.getComponent(slider_widget).initView((scale:number)=>{ if(!this.slider_status){ this.slider_status = true; } this._x = parseInt(this.edit_x.string); let x =`${this._x +(scale>1?5:-5)}` this.edit_x.string = x; this.change() },()=>{ console.log("end_call") this.slider_status = false; }) this.slider_y.getComponent(slider_widget).initView((scale:number)=>{ if(!this.slider_status){ this.slider_status = true; } this._y = parseInt(this.edit_y.string); let y =`${this._y +(scale>1?5:-5)}` this.edit_y.string = y; this.change() },()=>{ this.slider_status = false; }) } change(){ if(this.call_back!=null){ this.call_back(new Vec3(parseInt(this.edit_x.string),parseInt(this.edit_y.string),parseInt(this.edit_z.string))) } } }