1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import { __GoodData } from "../data/sdata/SManage";
- import FTmpTaskPanel from "./FTmpTaskPanel";
- /**
- * 临时道具
- */
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class FTmpTaskGood extends cc.Component {
- @property(cc.Label)
- mCount: cc.Label = null;
- @property(cc.Sprite)
- mIcon: cc.Sprite = null;
- public _good:__GoodData;
- public count:number;
- private callback:(goodItem:FTmpTaskGood,isActive:boolean)=>void
- onLoad(){
- this.node.on(cc.Node.EventType.TOUCH_START, this._touchStartEvent, this);
- this.node.on(cc.Node.EventType.TOUCH_END, this._touchEndEvent, this);
- this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._touchEndEvent, this);
- }
- public init(good:__GoodData,count){
- this._good = good;
- this.count = count;
- this.mCount.string = 'x'+count
- cc.resources.load('icon/good/'+good.icon, cc.SpriteFrame, (err, spriteFrame:cc.SpriteFrame) =>{
- if(err){
- cc.error(err);
- }else{
- this.mIcon.spriteFrame = spriteFrame;
- }
- });
- }
- public setCallback(callback:(goodItem:FTmpTaskGood,isActive:boolean)=>void){
- this.callback = callback
- }
- private _touchStartEvent(event) {
- this.callback(this,true)
- }
- private _touchEndEvent() {
- this.callback(this,false)
- }
- }
|