Jetton.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. // m_atlas: cc.SpriteAtlas,
  5. },
  6. onLoad: function () {
  7. this.Init();
  8. },
  9. start: function () {
  10. this.Init();
  11. },
  12. Init: function() {
  13. if(!this.m_Data) {
  14. this.m_Data = new Object();
  15. this.m_Data.value = 0;
  16. this.m_Data.score = 0;
  17. }
  18. },
  19. SetData: function (Param) {
  20. this.Init();
  21. this.m_Data.value = Param.value;
  22. this.m_Data.score = Param.score;
  23. this.m_Data.atlas = Param.atlas;
  24. this.m_Data.bundle = Param.bundle;
  25. this.m_Data.url = Param.url;
  26. if(this.m_Data.atlas) {
  27. this.node.getComponent(cc.Sprite).spriteFrame = this.m_Data.atlas.getSpriteFrame('' + this.m_Data.value);
  28. } else {
  29. if(this.m_Data.bundle && this.m_Data.url) {
  30. cc.gPreLoader.LoadRes(`${this.m_Data.url}_${this.m_Data.value}`, this.m_Data.bundle, function(sf, Param){
  31. this.node.getComponent(cc.Sprite).spriteFrame = sf;
  32. }.bind(this));
  33. } else {
  34. cc.gPreLoader.LoadRes(`Image_${this.m_Data.value}`, `Jetton_2`, function(sf, Param){
  35. this.node.getComponent(cc.Sprite).spriteFrame = sf;
  36. }.bind(this));
  37. }
  38. }
  39. },
  40. Move: function(pos, dt, delay, StartCallback, EndCallback, Hook) {
  41. StartCallback();
  42. var act = cc.sequence(cc.delayTime(delay ? delay : 0), cc.moveTo(dt, pos), cc.callFunc(EndCallback, Hook, this));
  43. this.node.runAction(act);
  44. },
  45. GetData: function() {
  46. return this.m_Data;
  47. },
  48. });