Add "postUpdate" function into UpdateList module

54 views
Skip to first unread message

Pin-Hua Tien

unread,
Feb 6, 2018, 4:47:38 AM2/6/18
to Phaser 3 Development
"gameObject.preUpdate" function will be invoked in UpdateList.update function, triggered by 'update' event of scene.sys, which is ran before scene.update function (user domain application)

Will it have benefit to add "gameObject.postUpdate" function, triggered by 'postupdate' event of scene.sys which is ran after scene.update function in UpdateList.postUpdate function?

i.e.
1. gameObject.preUpdate
2. scene.update
3. gameObject.postUpdate

Richard Davey

unread,
Feb 6, 2018, 6:13:04 AM2/6/18
to Pin-Hua Tien, Phaser 3 Development
Rather than do this automatically for every Game Object, you could make it listen for the event:

this.events.on('postupdate', sprite.postUpdate);

Alternatively, you could extend the UpdateList to make that listen for the Scene postUpdate instead, and then iterate all of its children.

I guess it depends on quantity. If you had loads of sprites needing to do this, I'd extend and use the UpdateList, if it was only a few, I'd just listen for the event directly.



Photon Storm Ltd.

Skype: richard.davey
Twitter: @photonstorm

Registered in England and Wales.
Company ID: 8036404
VAT Number: 136 4333 27

--
You received this message because you are subscribed to the Google Groups "Phaser 3 Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phaser3-dev+unsubscribe@googlegroups.com.
To post to this group, send email to phase...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/phaser3-dev/45fbeca5-222d-464b-88b6-f18243e08c59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rex

unread,
Feb 6, 2018, 7:05:38 AM2/6/18
to Phaser 3 Development
Good suggestion, thank you.

I am trying to build a system which could modify properties of game object in preUpdate function. For example, rotate game object each tick could be encapsulated into a "rotate behavior", i.e. run behavior[i].preUpdate() inside gameobject.preUpdate function. behavior[i].postUpdate() in gameobject.postUpdate() is similar.

Since trigger event should be removed when game object had been destroyed. It is better to extend UpdateList module by myself to support invoking gameobject.postUpdate() function.

BTW, plugin system is useful, it could encapsulate code in scene.update into reuse-able pieces. Thank you to add it in phaser3.



Richard Davey於 2018年2月6日星期二 UTC+8下午7時13分04秒寫道:
Rather than do this automatically for every Game Object, you could make it listen for the event:

this.events.on('postupdate', sprite.postUpdate);

Alternatively, you could extend the UpdateList to make that listen for the Scene postUpdate instead, and then iterate all of its children.

I guess it depends on quantity. If you had loads of sprites needing to do this, I'd extend and use the UpdateList, if it was only a few, I'd just listen for the event directly.



Photon Storm Ltd.

Skype: richard.davey
Twitter: @photonstorm

Registered in England and Wales.
Company ID: 8036404
VAT Number: 136 4333 27

On 6 February 2018 at 09:47, Pin-Hua Tien <binhu...@gmail.com> wrote:
"gameObject.preUpdate" function will be invoked in UpdateList.update function, triggered by 'update' event of scene.sys, which is ran before scene.update function (user domain application)

Will it have benefit to add "gameObject.postUpdate" function, triggered by 'postupdate' event of scene.sys which is ran after scene.update function in UpdateList.postUpdate function?

i.e.
1. gameObject.preUpdate
2. scene.update
3. gameObject.postUpdate

--
You received this message because you are subscribed to the Google Groups "Phaser 3 Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phaser3-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages