12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- const DWTool = require("../utils/DWTool");
- cc.Class({
- extends: cc.Component,
- properties: {
- itemSprite: cc.Sprite,
- selectedSprite: cc.Sprite,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- GameEvent.on('StoreDiamondSelect', this, (index) => {
- this.selectedSprite.node.active = this._index == index;
- });
-
- },
- init(index) {
- this._index = index;
- this.node.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
- GameEvent.fire('StoreDiamondSelect', this._index);
- }, 500, true), this);
- let imageIndex = index + 1;
- DWTool.loadResSpriteFrame(`./textures/store/store_diamond_${imageIndex}`)
- .then((spriteFrame) => {
- this.itemSprite.spriteFrame = spriteFrame;
- });
- },
- start () {
- },
- onDestroy() {
- GameEvent.off('StoreDiamondSelect', this);
- }
- // update (dt) {},
- });
|