12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import { _decorator, Component, EditBox, Node, Size } from 'cc';
- import { ClientEvent } from '../../clientEvent';
- import { config } from '../../config';
- import { slider_widget } from './slider_widget';
- import { Attributes } from '../Attributes';
- const { ccclass, property } = _decorator;
- @ccclass('attributes_w_h')
- export class attributes_w_h extends Component {
- @property(EditBox) edit_w:EditBox = null;
- @property(EditBox) edit_h:EditBox = null;
- @property(Node) slace_W_h:Node = null;
- private _w:number = 0;
- private _h:number = 0;
- private call_back = null;
- private slider_status:boolean = false;
- public update_att(w:number,h:number){
- this.edit_w.string = w.toFixed()
- this.edit_h.string = h.toFixed()
- this._w = 0;
- this._h = 0;
- }
- public initView(call){
- this.call_back = call;
- this.edit_w.node.on('editing-did-ended', this.change, this);
- this.edit_h.node.on('editing-did-ended', this.change, this);
- this.slace_W_h.getComponent(slider_widget).initView((scale:number)=>{
- if(!this.slider_status){
- this._w = parseInt(this.edit_w.string);
- this._h = parseInt(this.edit_h.string);
- this.slider_status = true;
- }
- let w =`${this._w*scale}`
- let h =`${this._h*scale}`
- this.edit_w.string = w;
- this.edit_h.string = h;
- this.change()
- },()=>{
- this.slider_status = false;
- })
- }
- change(){
- if(this.call_back!=null){
- this.call_back(new Size(parseInt(this.edit_w.string),parseInt(this.edit_h.string)))
- }
- }
- }
|