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
[next] Return of the Stage #4586
Conversation
@endel original Added/Removed events PR author , #1870 Flash has two type of events: Just a reference, found your code related to stage: https://github.com/gamestdio/pixi-engine/blob/master/src/PixiPatches.ts#L8 |
Hi @ivanpopelyshev, Here's the description of
AFAIK, it's not possible to have On pixi-engine, I've monkey-patched the On Flash the events always bubble through the whole display list, and it is possible to listen for events from the root (or any of its parents), and manipulate any deeper IMHO having a Cheers! |
@@ -52,6 +52,8 @@ export default class Application | |||
* for devices with dual graphics card **webgl only** | |||
* @param {boolean} [options.sharedTicker=false] - `true` to use PIXI.Ticker.shared, `false` to create new ticker. | |||
* @param {boolean} [options.sharedLoader=false] - `true` to use PIXI.Loaders.shared, `false` to create new Loader. | |||
* @param {PIXI.Container} {options.stage} - Pass existing stage or container | |||
* @param {number} {options.animationDeltaMax} - How many frames will be processed by animation if user switches the tab |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
55-56 missing dots :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I think this can be addressed as separate PR, we can add this to CI or somewhere
|
||
onRemoved() | ||
{ | ||
// Text frees videomemory when it leaves the stage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move to the docblock?
import Runner from 'mini-runner'; | ||
|
||
/** | ||
* Stage is a Container that takes care of add/remove events and animations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for me, I don't quite get a reason to have multiple stages.
Would be cool to add short example/use-cases in docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something like your description is a great thing to put here.
Just maybe make it more compact.
faster detach more detach improvements tests are failing. Its ok, those are really good tests. tests are fine! ParticleContainer does not spam the stage. More animation parameters Text optimization empty functions lint multistage animation detach test animated removal solved! onAnimate fixes derpy mcderp animate through nested stage
615e1e7
to
6d2c7ae
Compare
@GoodBoyDigital and I have discussed and we have decided to close this omnibus PR because of the unwanted complexity it would add to v5, it's incompleteness (failing tests), added API surface, and a failure to see community enthusiasm for this approach. However, there may be smaller incremental PRs within this one (e.g., the ability to provide a "stage" container for Application options, adjustments to inherited animation time/ticks, a way to add/remove children without events) but overall all the functionality within this Stage implementation is probably best as an external plugin or system for Pixi. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Work in progress - need reviews
What if we rename
detachChild
intoremoveLater
,silendRemoveChild
orstealChild
?The time has come! Russian Christmas update!
Follow #4179 , I kept it very simple.
This is colossal PR that was waited too long, people really want correct
added
andremoved
events and a way to track all animations that exist in main stage tree. This is critical for projects that need to free resources and count references to them, also for projects that require managable tweens and animations.InnerStage
tracks sets of DisplayObjects and Containers that exist in the stage, some in detached stage. 170 lines of serious algorithm code were always on used-side.parentStage
property always points to the stage where the object is registered.As a default implementation that can be easily changed in plugins and in user-side code, any object that has
animate
method will be called when the time comes. It can be changed both by overriding Stage methods and handlingadded
andremoved
events.There can be nested stages.
Better Events
added
andremoved
are fired for whole subtree.Additional way of moving objects in the same stage without firing events:
detachChild
. It exists in cocos2d-x as a flag toremoveChild
, which is not verbose.Generated Resources: Dispose vs Destroy
Alternative to
destroy
method, just overrideonRemoved
or register a handler.This snippet automatically frees videomemory of unstaged text:
Fallback
Use
PIXI.Container
as a root.added
andremoved
events wont be fired in that case.Solution for remove at animate problem
Suppose you animate spine object or AnimatedSprite and want to remove that thing from the stage from inside of event.
That can really affect neighbour elements, or even throw an exception. Any event fired from inside animation or old updateTransform can trigger that response.
With
detachChild
it will work just fine.