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
Exteneded GameObject (Sprite) not fire update method, but preUpdate #3378
Comments
@photonstorm Why is this complex/difficult? I just ran into this myself as the Sprite docs even state that 'update' is to be overridden. |
I'm surely too naive about this... but I'll ask anyway. Why can't we just add 'update' call after this line: |
See #3379 (comment). |
Doing this.scene.on('update', this.update) for now. Thank you for the reference @samme ! |
It’s flagged as complex because it requires a significant refactor to the internals, the creation of a new plugin and changes to how Groups work. To do this right touches lots of elements. |
Going to close this issue. These are plugins available to address this, and it's just the way v3 works. Will re-consider for v4. |
@kalebwalton This did not work for me. However, this works (Phaser v3.21.0): this.scene.events.on('update', (time, delta) => { this.update(time, delta)} ); I wrote a class that extends |
So... when you extend a class in this framework, it changes behavior? Am I reading this correct? How terribly confusing and frustrating. I was trying to resolve why my |
@juanitogan classes do not change behavior when extended as
|
Ah, I see. That adds up. Thank you for the explanation. I was having a hard time imagining how extending a class could change its behavior... even in mysterious JavaScript. I could only imagine that something else was detecting an extended class somehow for some odd reason. When doing closer comparative reading between Scenes and GameObjects, I can now (and only now) see meaning in the nuances in text between the update methods for each. There is just so much to dig through to catch it all. And... just because an object may be on a scene's update list, it doesn't mean it will get an update event. That is finally becoming clearer as well. Surprising... but, okay, that's Phaser. I can see the logic in keeping the number of updated objects to a minimum... I just missed the clues on this pattern and how to work with it. As a side note: This is a very hard engine to learn indeed. Unity felt easier to learn, and that's a pretty gnarly beast. Here, I run into a surprise like this about every other day and spend way too much time going in circles in the docs trying to reconcile it. I don't mean to sound overly critical -- I'm amazed by the amount of work and energy here -- this just may not be the engine for me. I'm considering switching to a WebAssembly solution -- not for speed but for thinner and simpler tools. Not sure yet. I'm only about 5000 lines in and my code is already a mess of programming patterns and workaround notes. Some OO best practices and guide would be a nice-to-have. In case anyone is curious, this is what I'm working on: https://juanitogan.itch.io/sendit-soccer |
It's little bit wierd but all extened Sprites in V2 fires update method in class, but right now update not working. I discovered in UpdateList that is preUpdate is fired. But I think this solution is not clean as should be and can avoid some backend process.
Look at
TestSprite.update
andTestSprite.preUpdate
https://jsfiddle.net/athntebo/19/
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: