zxlostsoul Posted March 6, 2016 Share Posted March 6, 2016 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: Looks like pixels from another frames has been used when sprites are resizing. Tell me please, how to fix it? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 7, 2016 Share Posted March 7, 2016 is your sprite coordinates fractional? Quote Link to comment Share on other sites More sharing options...
zxlostsoul Posted March 7, 2016 Author Share Posted March 7, 2016 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); } } Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 7, 2016 Share Posted March 7, 2016 You have to add transparent border so linear filtering wont affect your spritesheet. TexturePacker has that option when it generates atlas from multiple files. Also, if you want to use mip-mapping , border must be larger. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 7, 2016 Share Posted March 7, 2016 Also, if you are working with tiles, you can use https://github.com/pixijs/pixi-tilemap , just dont use "true" parameter, your sprites arent squares. 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.