SelectSceneItem.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. const { ccclass, property } = cc._decorator;
  8. @ccclass
  9. export default class SelectSceneItem extends cc.Component {
  10. @property(cc.Sprite)
  11. spr_selectScene: cc.Sprite = null;
  12. public sceneIndex: number = null;
  13. // LIFE-CYCLE CALLBACKS:
  14. // onLoad () {}
  15. start() {
  16. }
  17. // update (dt) {}
  18. init(sceneIndex: number = null) {
  19. this.sceneIndex = sceneIndex;
  20. if (sceneIndex != null) {
  21. mk.loader.load(`selectScene/${this.sceneIndex}`, cc.SpriteFrame).then((spriteFrame) => {
  22. this.spr_selectScene = spriteFrame;
  23. })
  24. }
  25. else {
  26. mk.loader.load(`selectScene/${this.sceneIndex}`, cc.SpriteFrame).then((spriteFrame) => {
  27. this.spr_selectScene = spriteFrame;
  28. })
  29. }
  30. }
  31. }