Jump to content

Spritesheet frames trimming


zxlostsoul
 Share

Recommended Posts

adult@test.png.869f2e1151e0dc1c0eb9c5a76

I use this image as spritesheet. Second frame is completely empty (transparent). I crop image into frames:

frame=new PIXI.Texture(texture.baseTexture, new PIXI.Rectangle(x, y, frame_width, frame_height)));

But when I try to draw second frame, I see a garbage from another frames:

2016-03-07_034141.png.4764ec916628db9b9d

Looks like pixels from another frames has been used when sprites are resizing. Tell me please, how to fix it?

Link to comment
Share on other sites

11 hours ago, ivan.popelyshev said:

is your sprite coordinates fractional?

No, it is not. I write a demo to show my problem: http://zxlostsoul.4ky.ru/pixi/

Full code:

window.onload = function() {
	var renderer = PIXI.autoDetectRenderer(800, 600,{backgroundColor : 0x1099bb});
	document.body.appendChild(renderer.view);
	var stage = new PIXI.Container();

	var sprite = PIXI.Sprite.fromImage('./img/test.png');
	var texture=new PIXI.Texture(sprite.texture, new PIXI.Rectangle(24, 0, 24, 48));
	var frame=new PIXI.Sprite(texture);

	frame.position.set(230,264);
	frame.scale.x=4;
	frame.scale.y=4;
	stage.addChild(frame);

	animate();
	function animate() {
		renderer.render(stage);
		requestAnimationFrame(animate);
	}
}

 

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