Skip to content
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

state "create" method being called twice when using "In" transition #17

Closed
ThomasDotCodes opened this issue Feb 27, 2016 · 14 comments
Closed
Assignees
Labels

Comments

@ThomasDotCodes
Copy link

When I pass in the optional In transition, the create method is being called twice. Just wondering if this is intended, as it seems like it might be unnecessary.

How I'm calling:
game.state.start('MainMenu', Phaser.Plugin.StateTransition.Out.SlideRight, Phaser.Plugin.StateTransition.In.SlideRight);

@cristianbote
Copy link
Owner

Good question!

First I was pretty sure it's a bug, but it turns out, that it does make sense.
So about what is happening, when using the slide in options, basically the next state needs to be drawn to have something to slide in. Therefore, the first call is just to get the snapshot and then it gets cleared. When the transition in has finished the create method is called again, but for good this time.

Reference https://github.com/cristianbote/phaser-state-transition/blob/master/src/core/StateManagerStart.js#L23

Now that you've brought this to light - something that I have clearly missed, I think I should warn the users, whenever they fancy a slide-in animation for that state, that they should be careful about it, since instantiating twice the state, could lead to bad results.

Thanks for asking. I really appreciate it!

Note: I'm opened to suggestions, so if any, let me know.

@ThomasDotCodes
Copy link
Author

thanks for the response. Just curious, is it not possible to take the snapshot without clearing the state? Or perhaps take a snapshot of the current state first, then instead of 'sliding in' the new one, you create the new state, put the snapshot on top, then slide out the snapshot to reveal the current (new) state underneath?

It seems that might avoid the need of initializing the new state twice.

@cristianbote
Copy link
Owner

So this is what's happening right now, without using the sliding in option.
Sliding in is pretty problematic. If let's say, I would create just once the snapshot, and leave the state, then you'll end up having 'dead time' at the beginning of the state.

Just talking about it, makes me look even more into the issue. I'm pretty sure I'll remove the support for transition in for states, down the road, but we'll see.

@shohan4556
Copy link

I have the same problem, when I tested my game on samsung galaxy its ok but when I tested it on lenovo it occurs, my question is there any way to get rid of this. sometimes it looks bad.

@cristianbote
Copy link
Owner

Hey!

Yup. Do not use a transition for 'in' state. That means, no third parameter to game.state.

@Montoya
Copy link

Montoya commented Mar 1, 2016

Is there going to be some solution for this? I really like the way it looks when combining slides for both out and in. Is it really necessary to clear the state and call create again when the transition completes?

@shohan4556
Copy link

please take a look this gif gif
this is the code I have added this.game.state.start('Credit',Phaser.Plugin.StateTransition.Out.SlideTop);

when I clicked the button its sliding twice.

@cristianbote
Copy link
Owner

@Montoya working on it.

@shohan4556 that's not pretty. Check out this example https://jsfiddle.net/cristianbote/xen8usb9/ and maybe there's something you're missing.
Also, make sure, you don't call twice the game.state.start, cause that can be something that could look similar.

Reopened and working on a fix.

@cristianbote cristianbote reopened this Mar 1, 2016
@cristianbote cristianbote added bug and removed question labels Mar 1, 2016
@shohan4556
Copy link

I did not call 'game.state.start' twice. It happens when I choose iphone or nokia lumia which has DPR 2+ or more.

@cristianbote
Copy link
Owner

There's no relation between dpr and the transitions. Open up the result https://jsfiddle.net/cristianbote/xen8usb9/embedded/result/ on the devices and see if it's reproducible.

@shohan4556
Copy link

Thanks for the reply, surely I will give a try at the moment I am busy now.

cristianbote added a commit that referenced this issue Mar 3, 2016
#17: Added _created overwrite between transition out and in
@cristianbote
Copy link
Owner

Alright, I just did a new push, to fix this behavior. Let me know if there's anything related to it.

Cheers!

@Montoya
Copy link

Montoya commented Mar 4, 2016

OK I just dropped in the latest build and tried a slide left for both out & in, and this is what I'm seeing:

transition

@shohan4556
Copy link

Its ok now I just tested it, Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants