-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transitioning between two scenes #302
Comments
Hello, There are probably a couple of things to discuss about the MVC architecture. But let's start to look at the most obvious reason why you're having issues. The code in You should not put code that is about initialising the scene, like loading assets, placing them, etc. This should belong to the The If we follow our old_scene, once we call I must say that this has also surprised me in the beginning. I've also looked for ways to determine if my Scene was the active scene or if it was on stage just because it's in a transition. The way to check that is to check if You might find this discussion useful. Dan |
Thanks for your feedback, I understand how it works better now. Can you keep the issue open ? Once things are completely clear in my mind i would like to update the site with more detailed explanation. |
Hello, I said earlier that there were other things to mention about the MVC structure. So here it is. The view should subscribe to the model events and update ... well its view according to the model states. Regarding the loading, it's a bit of a code smell to read that you want to access an instance without its assets loaded. Maybe I'm wrong. But it could be that you put too much in one class. Otherwise if this is really what you need, you should google lazy loading which is a technique for loading something expensive in memory only when required. I'd love you to update the documentation to clarify anything that was not clear for you! Document love is always good. ❤️ I don't see a problem keeping this opened while you look into things. @ccanepa any objections? |
no problem |
I am 100% sure I must be doing something wrong, but I'm going to open this one at least for the sake of clarification.
A bit of context
I am currently developing some sort of RPG, nothing big, just a sequence of Visual Novel-like dialog Scenes and Battle Scenes. I am currently working on making dialog work.
Individual Dialog Scenes are working perfectly fine but transitioning between different scenes currently gives an horrible mess.
The code
As I wanted to implement an MVC pattern, the code goes as follow
On the model side, nothing much, merely a list of dialog-lines/fade-in/etc... scheduled and calls to the view to modify it. It works exactly as expected, so i will not develop the code in order to keep this as short as possible
On the view side, I use a personal subclass of layer.Layer that contains other subclasses of layer.Layer corresponding to :
- the background Image
- the foreground and its sprites (cocos.sprite.Sprite)
- the sound system (I directly use pyglet's + AVBin for this)
The view - at least on a single individual scene - display what i want so I'm not going to develop it either for the same reason as above
On the control side, I define a generic subclass of scene
the .load() methods are used to : get the sprites, position them, get the background image, and play some sound, and generate the model's list
For each given dialog scene, I override load (for both view and model) which leads to something like this in view's case :
DialogSceneControl class (a subclass of layer.Layer) is used to deal with user-generated events as such
What works
As long as I use each scene without transition, I can put them all in a scenes.sequences.SequenceScene
and override next_scene in order to call director.pop(), there will be no neat transition effect, but each scene displays the way it should ('Rose' appears then talks then 'Snow' appears and talks).
So I wanted to add a smooth Fade effect
Where it fails
From what i understood from the documentation and https://github.com/liamrahav/cocos2d-python-tutorials/blob/master/basics/transitions.py , what I should be having in order to make this work is a main like this :
And S1dialogScene (subclass of the above DialogScene) should override next_scene to go to the transition. Which I tried like so :
(S2dialogScene's next_scene is basically just a director.pop on an empty scene_stack thus normally the end of the application)
When I do this, the director does an awkward enter-exit of both scenes, here is the trace when i put print on the specific overrides of on_enter, on_exit, next_scene
And the on-screen results is even more awkward. The first scene goes without problem until it reaches its end. Then it flashes out, goes to the transition scene, isn't cleaned properly, the second scene half-begins, then isn't cleaned properly. And Finally it blinks out of the transition scene, into a silent second scene that runs twice.
The behaviour I am trying to achieve
The First Scene freezes in its current state. The Second Scene loads off-screen. The first scene fades out. The second scene fades in.
There is certainly something wrong the way i coded this but I can't seem to find it using the documentation.
The text was updated successfully, but these errors were encountered: