LoadMainScene.ts 731 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { _decorator, Component, Node,Button,director,assetManager,Prefab, tween } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('LoadMainScene')
  4. export class LoadMainScene extends Component {
  5. @property(Button)
  6. private button: Button | null = null;
  7. onLoad() {
  8. if (this.button) {
  9. this.button.node.on(Button.EventType.CLICK, this.callback, this);
  10. }
  11. }
  12. start() {
  13. }
  14. update(deltaTime: number) {
  15. }
  16. callback() {
  17. const sceneName = 'Main';
  18. director.loadScene(sceneName, (err, scene) => {
  19. if (err) {
  20. console.error('场景加载失败:', err);
  21. return;
  22. }
  23. });
  24. }
  25. }