CarItem.js 758 B

123456789101112131415161718192021222324252627282930
  1. var ItemType = require("ItemType");
  2. var CarItem = cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. nameLbl:cc.Label,
  6. icon:cc.Sprite,
  7. Atlas:cc.SpriteAtlas,
  8. Data:null,
  9. },
  10. init:function (data) {
  11. this.icon.spriteFrame = this.Atlas.getSpriteFrame(data.icon);
  12. this.Data = data;
  13. },
  14. ClickBuy:function () {
  15. cc.Mgr.AudioMgr.playSFX("click");
  16. var param = {};
  17. param.name = this.Data.name;
  18. param.icon = this.Data.icon;
  19. param.Id = this.Data.Id;
  20. param.Type = ItemType.Car;
  21. param.price = this.Data.price;
  22. param.flag = "Buy";
  23. cc.director.GlobalEvent.emit(cc.Mgr.Event.OpenCommonBuy, param);
  24. },
  25. });
  26. module.exports = CarItem;