123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- // 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))
- }
- })
- }
- }
|