Jump to content

Update world x and y properties


Arin D
 Share

Recommended Posts

Hi, i have a a sprite , hierarchy as follows  mainContainer.childContainer1.sprite

const app = new PIXI.Application({.....

const renderer = app.renderer

renderer.render(mainContainer)

I can find the world x and y of sprite, but how do i set those values? I mean I want to change those values with respect to canvas.

Using pixi 5 legacy

thanks

 

Link to comment
Share on other sites

if you use `render()` directly and not from application ticker, you should use `new PIXI.Renderer`, not the application. https://github.com/pixijs/pixi.js/wiki/v5-Custom-Application-GameLoop

As for coordinates problem, something like "mainContainer.toLocal(globalPos, undefined, sprite.position)" should work. that means it will convert globalPos to local coordinates of mainContainer and put it all to "sprite.position". Its not easy to explain this. Every time I use that thing, I open "DisplayObject.js" source code to remember how exactly does it work.

Link to comment
Share on other sites

Thanks for the reply ? 

if I use new PIXI.Renderer, i get error " This browser does not support WebGL. Try using the canvas renderer", where is the fallback to canvas ? i thought pixi 5 legacy maintains the fallback to canvas ?

and mainContainer.toLocal(globalPos, undefined, sprite.position) did not do what i intended to do, there is also lack of sufficient documentation to get help on this, all i want is to change x and y of sprite with respect to global (world), anyway, will keep trying

 

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