Jump to content

Childs Ticker Listener


Recommended Posts


I have a PIXI app with many child (in a tree structure). I need to update only child that contains the method "update". There is any logic inside PIXI for this or I would need to add each of those object in the shared.ticker? 

I did this, but there could be a better way that could allow me to remove the ticker listener if I need to. THIS IS NOT FOR SPRITE ANIMATIONS, it's mostly to change objects position




Link to comment
Share on other sites


Im not liking to do so many hack but I don't see other way to do it without waiting for new releases. 

Please give me you opinion on this, would this fail in any scenario?



PIXI.Container.prototype.onChildrenChange = function(childIndex){  
  let child = this.children[childIndex]
  console.log(childIndex, this.children)
  if(this.children.length > 0 && child.hasCustomEvents != true){
    child.hasCustomEvents = true

	//Define here any custom event
    let customEvents = ['update','render']

    for(let i=0;i<customEvents.length;i++){
      let eventName = customEvents[i]
      if(typeof child[eventName] == 'function'){
          console.log('LISTENER ADDED',eventName, child[eventName])
          console.log('LISTENER REMOVED',eventName, child[eventName])



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...