Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3978

How to use defaultAnchor from Texture ?

$
0
0

Hello

I would like to configure offsets on texture (not on sprites).

Why this example does not work ?

const app = new PIXI.Application({
	resizeTo: window,
  backgroundColor: 0x999999
});
document.body.appendChild(app.view);
PIXI.Assets.add('bunny', 'https://pixijs.io/examples/examples/assets/bunny.png'); 
PIXI.Assets.load(['bunny']).then((textures) =>
{
	let texture = textures['bunny'];
  
  let tmp = new PIXI.Texture(
    texture, 
    new PIXI.Rectangle(
      0,
      0,
      20,
      20,
    )
  );
  texture.defaultAnchor.x = 30; // wrong instruction ? Does not work
  const sprite = PIXI.Sprite.from(tmp);
  app.stage.addChild(sprite);
});

Thanks,


Viewing all articles
Browse latest Browse all 3978

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>