Reputation: 1
I am working on simple 2d game and trying to transition from game scene to next scene (game over or game won) depending on the collision with certain objects in game scene.
When I call the NextScene function from the game scene the code works fine if I use director.replace(scene) but fails when I am trying to use animated transitions - for example director.replace(FlipX3DTransition(scene, duration=2)). Below is the chunk of the code and error message:
def NextScene(scene, transition = None):
if transition:
return cocos.director.director.replace(transition(scene, duration=2))
else:
return cocos.director.director.replace(scene)
Exception: Incoming scene must be different from outgoing scene.
Upvotes: 0
Views: 259
Reputation:
You seem to get the error because you are trying to replace a running scene with itself. The check for equal scenes is made when you create a FlipX3DTransition
(or any other TransitionScene
). There is no such check in cocos.director.director.replace
.
Upvotes: 0