123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- // 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 footstepmove from "./footstepmove";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class NewClass extends cc.Component {
- @property(cc.Label)
- label: cc.Label = null;
- @property
- text: string = 'hello';
- // LIFE-CYCLE CALLBACKS:
- onLoad() {
- // let item = this.node.getChildByName("view").getChildByName("content").getChildByName("item")
- // item.on('click', () => {
- // console.log(item.name);
- // }, this)
- }
- start() {
- let content = this.node.getChildByName("view").getChildByName("content")
- let bgprefabs = this.node.getChildByName("view").getChildByName("bg1")
- for (let index = 1; index < 444; index++) {
- const url = "res/bg/bg" + index
- // cc.resources.load(url, cc.SpriteFrame, (err, spriteframe) => {
- // if (err) {
- // return
- // }
- // let a = cc.instantiate(bgprefabs);
- // let sprite = a.getComponent(cc.Sprite);
- // a.parent = content
- // a.active = true
- // sprite.spriteFrame = spriteframe;
- // a.on('touchstart', () => {
- // if (window['selectNode']) {
- // let tempSprite = window['selectNode'].getComponent(cc.Sprite) as cc.Sprite
- // tempSprite.spriteFrame = spriteframe
- // }
- // })
- // });
-
- let bundle = cc.assetManager.getBundle("sub");
- bundle.load(url, cc.SpriteFrame, (err: Error, spriteframe: cc.SpriteFrame) => {
- if (err) {
- return
- }
- let a = cc.instantiate(bgprefabs);
- let sprite = a.getComponent(cc.Sprite);
- a.parent = content
- a.active = true
- sprite.spriteFrame = spriteframe;
- a.on('touchstart', () => {
- if (window['selectNode']) {
- let tempSprite = window['selectNode'].getComponent(cc.Sprite) as cc.Sprite
- tempSprite.spriteFrame = spriteframe
- }
- })
- });
- }
- let footstep = cc.Canvas.instance.node.getChildByName("footstep")
- let footstepcontent = footstep.getChildByName("view").getChildByName("content")
- for (let index = 0; index < 3000; index++) {
- const url = "res/footstep/footstep" + index
- // cc.resources.load(url, cc.Prefab, (err, Prefab) => {
- // if (err) {
- // return
- // }
- // let a = cc.instantiate(Prefab);
- // a.parent = footstepcontent
- // a.active = true
- // a.setContentSize(80, 80)
- // a.on('touchstart', () => {
- // console.log(1);
- // if (window['selectNode']) {
- // let temppp = cc.instantiate(Prefab)
- // temppp.parent = window['selectNode']
- // temppp.addComponent(footstepmove)
- // }
- // })
- // });
- let bundle = cc.assetManager.getBundle("sub");
- bundle.load(url, cc.Prefab, (err: Error, Prefab) => {
- if (err) {
- return
- }
- let a = cc.instantiate(Prefab);
- a.parent = footstepcontent
- a.active = true
- a.setContentSize(80, 80)
- a.on('touchstart', () => {
- console.log(1);
- if (window['selectNode']) {
- let temppp = cc.instantiate(Prefab)
- temppp.parent = window['selectNode']
- temppp.addComponent(footstepmove)
- }
- })
- });
- }
- }
- }
|