Jump to content

How to access sprite object in updateTransform callback in ReactPixi (@pixi-react)


Anonymous1994
 Share

Recommended Posts

Pixi.js added an onRender callback that is called every frame in v8, however ReactPixi seems to only have support for Pixi.js v7, so I have to use updateTransform. The documentation below states about updateTransform - "many people used this function to do custom logic every frame"

https://pixijs.com/8.x/guides/migrations/v8?_highlight=onrender#other-breaking-changes

How can I access the sprite object from within updateTransform? I would assume its the argument of the callback, but doing console.log(sprite) gives undefined...

Also, why does updateTransform move my sprite on the screen?

Thanks!

 

     <Sprite
            image={"../images/blue.png"}
            width={100}
            height={100}
            x={100}
            y={100}
            anchor={0.5}
            interactive={true}
            pointerdown={onDragStart}
            pointerup={onDragEnd}
            pointerupoutside={onDragEnd}
            pointermove={onDragMove} 
            rightdown={right}
            rightdowncapture={right2}
            updateTransform={(sprite) => {
              console.log(sprite)
            }}
          />

 

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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