// Learn TypeScript: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html import edLayout from "./edLayout"; const { ccclass, property } = cc._decorator; @ccclass export default class NewClass extends cc.Component { @property(cc.Node) MapNode: cc.Node = null; @property text: string = 'hello'; // LIFE-CYCLE CALLBACKS: onLoad() { // 获取当前节点 var node = this.node; // 为当前节点添加鼠标滑轮事件监听 node.on('mousewheel', this.onMouseWheel, this); } onMouseWheel(event) { // event.getScrollY() 返回1如果滚动向下,-1如果滚动向上 var scrollDirection = event.getScrollY(); if (scrollDirection > 0) { // up if (this.MapNode.scale <= 0.1) { } else { this.MapNode.scale = this.MapNode.scale - 0.1 if (this.MapNode.scale < 0.1) { this.MapNode.scale = 0.1 } else { } } } else { // down this.MapNode.scale = this.MapNode.scale + 0.1 } } protected start(): void { let Layout = this.node.getChildByName("New Layout").getComponent(edLayout) let heng = this.node.getChildByName("heng") let shu = this.node.getChildByName("shu") let hengButton = heng.getChildByName("New Button") let EditBox = heng.getChildByName("New EditBox").getComponent(cc.EditBox) hengButton.on('touchstart', () => { Layout.initx(parseInt(EditBox.string)) }) // for (let index = 1; index < 10; index++) { // if (index == 1) { // let Label = hengButton.getChildByName("Background").getChildByName("Label") // Label.getComponent(cc.Label).string = "" + index // hengButton.on('touchstart', () => { // console.log(index); // Layout.initx(index) // }) // continue // } else { // let temp = cc.instantiate(hengButton) // temp.parent = heng // let Label = temp.getChildByName("Background").getChildByName("Label") // Label.getComponent(cc.Label).string = "" + index // temp.on('touchstart', () => { // console.log(index); // Layout.initx(index) // }) // } // } let shuButton = shu.getChildByName("New Button") let EditBox1 = shu.getChildByName("New EditBox").getComponent(cc.EditBox) shuButton.on('touchstart', () => { Layout.inity(parseInt(EditBox1.string)) }) // for (let index = 1; index < 10; index++) { // if (index == 1) { // let Label = shuButton.getChildByName("Background").getChildByName("Label") // Label.getComponent(cc.Label).string = "" + index // shuButton.on('touchstart', () => { // console.log(index); // Layout.inity(index) // }) // continue // } else { // let temp = cc.instantiate(shuButton) // temp.parent = shu // let Label = temp.getChildByName("Background").getChildByName("Label") // Label.getComponent(cc.Label).string = "" + index // temp.on('touchstart', () => { // console.log(index); // Layout.inity(index) // }) // } // } let xuanzhuan = this.node.getChildByName("xuanzhuan") let xuanzhuanButton = xuanzhuan.getChildByName("New Button") let EditBoxxuanzhuan = xuanzhuan.getChildByName("New EditBox").getComponent(cc.EditBox) xuanzhuanButton.on('touchstart', () => { console.log(parseInt(EditBoxxuanzhuan.string)); if (window['selectfootstep']) { window['selectfootstep'].setRotation(parseInt(EditBoxxuanzhuan.string)) } }) let suofang = this.node.getChildByName("suofang") let suofangButton = suofang.getChildByName("New Button") let EditBoxsuofang = suofang.getChildByName("New EditBox").getComponent(cc.EditBox) suofangButton.on('touchstart', () => { console.log(parseInt(EditBoxsuofang.string)); if (window['selectfootstep']) { window['selectfootstep'].setScale(parseInt(EditBoxsuofang.string)) } }) } }