Akis Posted February 18, 2014 Share Posted February 18, 2014 How can I change the texture width/height but without any scaling of the texture in it? Basically, I just want to "cut" my sprite texture. If I update the 'width' or 'height' property, this will change the scaling. If I change the '_width' or '_height', it won't change anything :/ //edit: Hmm it seems I can achieve it by modifying the texture instead of the sprite.. The issue is that it will definitely altered the texture so if others sprites use the same texture, it won't work as expected :s Quote Link to comment Share on other sites More sharing options...
enpu Posted February 18, 2014 Share Posted February 18, 2014 I think if you want to crop your texture, you need to make a new one:var texture = PIXI.Texture.fromImage('sprite.png');var sprite = new PIXI.Sprite(texture);var texture2 = new PIXI.Texture(texture, new PIXI.Rectangle(10, 10, 50, 50));sprite.setTexture(texture2); Quote Link to comment Share on other sites More sharing options...
Akis Posted February 18, 2014 Author Share Posted February 18, 2014 omg that's exactly what I needed. Thank you. I first tried to clone the texture but didn't think about a specific constructor in Texture based on another texture. Thanks so much! Quote Link to comment Share on other sites More sharing options...
xerver Posted February 18, 2014 Share Posted February 18, 2014 Basically what you are trying to do is change the frame of the texture (the frame is a Rectangle object that defines the area of a BaseTexture that a Texture represents). What enpu's code does is create a new texture with the same base texture, but a different frame. Quote Link to comment Share on other sites More sharing options...
Akis Posted February 18, 2014 Author Share Posted February 18, 2014 Yep @xerver, as I'm modifying the width/height of the frame, that's exactly what I needed 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.