zacuve Posted March 3, 2019 Share Posted March 3, 2019 position (x, y) does not work capture http://prntscr.com/msqhg3 var my_photo = new PIXI.Sprite(resources.my_photo.texture); my_photo.width = 200; my_photo.height = 200; my_photo.position.x = 200; my_photo.position.y = 150; container.addChild(my_photo); var tex = this.app.renderer.generateTexture(container); var combinedSprite = new PIXI.Sprite(tex); //PIXI.loader.reset(); this.app.stage.addChild(combinedSprite); ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
zacuve Posted March 3, 2019 Author Share Posted March 3, 2019 I think the problem is here var tex = this.app.renderer.generateTexture(container); var combinedSprite = new PIXI.Sprite(tex); //PIXI.loader.reset(); this.app.stage.addChild(combinedSprite); Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 4, 2019 Share Posted March 4, 2019 generateTexture() doesnt remember position of element, it takes its bounds and renders everything inside to a texture (0,0)-(w,h). Usually, when i use it, i remember (x,y) of bounds to DEFAULT ANCHOR inside that texture somehint like var bounds = container.getBounds(); var texture = renderer.generateTexture(container, undefined, undefined, bounds); texture.defaultAnchor.set(-bounds.x / bounds.width, -bounds.y / bounds.height); then when you create the sprite , anchor will be automatically set. Do remember that sprite.position will still be 0, my method affects only anchor. zacuve 1 Quote Link to comment Share on other sites More sharing options...
zacuve Posted March 4, 2019 Author Share Posted March 4, 2019 thx @ivanpopelyshev Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.