Dialog.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. //秘书
  14. secretary: {
  15. default: null,
  16. type: cc.SpriteFrame,
  17. serializable: true,
  18. },
  19. worker: {
  20. default: null,
  21. type: cc.SpriteFrame,
  22. serializable: true,
  23. },
  24. businessman: {
  25. default: null,
  26. type: cc.SpriteFrame,
  27. serializable: true,
  28. },
  29. character: {
  30. default: null,
  31. type: cc.Node,
  32. serializable: true,
  33. },
  34. },
  35. // LIFE-CYCLE CALLBACKS:
  36. // onLoad () {},
  37. start() {
  38. },
  39. // update (dt) {},
  40. //切换图片
  41. onSetCharacterSprite(characterType) {
  42. switch (characterType) {
  43. case 'secretary':
  44. this.character.scale = 1;
  45. this.character.getComponent(cc.Sprite).spriteFrame = this.secretary;
  46. break;
  47. case 'worker':
  48. this.character.scale = 0.8;
  49. this.character.getComponent(cc.Sprite).spriteFrame = this.worker;
  50. break;
  51. case 'businessman':
  52. this.character.scale = 0.9;
  53. this.character.getComponent(cc.Sprite).spriteFrame = this.businessman;
  54. break;
  55. }
  56. }
  57. });