Skip to content

Discrepancy between instance scene switches and transitions when calling Director::getRunningScene() #2798

@rh101

Description

@rh101
  • axmol version:
  • devices test on:
  • developing environments
    • NDK version: r23c
    • Xcode version: 14.2+
    • Visual Studio:
      • VS version: 2022 (17.9+)
      • MSVC version: 19.39+
      • Windows SDK version: 10.0.22621.0+
    • cmake version:
      Steps to Reproduce:

This issue was raised in the discord server by @AlexandreK38

With normal scene switches, using pushScene or replaceScene, this is the sequence of calls and value of getRunningScene():

1. oldScene->onExit(), getRunningScene() = oldScene
2. newScene->onEnter(), getRunningScene() = newScene

If using transitions, this is what happens:

1. oldScene->onExit(), getRunningScene() = oldScene
2. newScene->onEnter(), getRunningScene() = oldScene

So, there is a difference in the value returned by getRunningScene() when using transitions. It should be the new scene, since onEnter() may have code that impacts the new scene (such as adding child nodes etc.).

The suggestion is to change the implementation of Director::setNextScene(), which will ensure that calling Director::getRunnningScene() in onEnter() will always return the new scene, regardless of how the scene switch occurs (push/replace or transition).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions