Jambutters Posted May 27, 2017 Share Posted May 27, 2017 let loaderSource = PIXI.loader.resources; let initPlayer = ():void =>{ let croped = PIXI.loader.resources["./img/player.png"].texture; let t32Rect = new PIXI.Rectangle(0, 0, 32, 32); // console.log(croped); croped.frame = t32Rect; let player = new PIXI.Sprite(loaderSource["./img/player.png"].texture); //this is not displaying the entire image, rather it's using the .frame clip. Shouldn't this be the independent whole image/texture? rootStage.addChild(player); console.log(player); }; Not sure why the Sprite displayed on PIXI is a cropped image rather than the whole thing. Shouldn't it be the entire thing ? Quote Link to comment Share on other sites More sharing options...
Jambutters Posted May 27, 2017 Author Share Posted May 27, 2017 Actually never mind... forgot that let croped does not create a copy , rather points directly to the texture Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 27, 2017 Share Posted May 27, 2017 Texture is a (baseTexture, frame). Sprite doesn't have frame. So you have to copy the texture, to achieve the thing you want. Texture in resources is a (baseTexture, (0,0,baseTexture.width, baseTexture.height)). You modified it and put in sprite - you got the result ``` let newTex = new PIXI.Texture(PIXI.loader.resources['lala'].texture, t32Rect); //same as let newTex = new PIXI.Texture(PIXI.loader.resources['lala'].texture.baseTexture, t32Rect); let sprite = new PIXI.Sprite(newTex); ``` Jambutters 1 Quote Link to comment Share on other sites More sharing options...
Jambutters Posted May 27, 2017 Author Share Posted May 27, 2017 4 hours ago, ivan.popelyshev said: Texture is a (baseTexture, frame). Sprite doesn't have frame. So you have to copy the texture, to achieve the thing you want. Texture in resources is a (baseTexture, (0,0,baseTexture.width, baseTexture.height)). You modified it and put in sprite - you got the result ``` let newTex = new PIXI.Texture(PIXI.loader.resources['lala'].texture, t32Rect); //same as let newTex = new PIXI.Texture(PIXI.loader.resources['lala'].texture.baseTexture, t32Rect); let sprite = new PIXI.Sprite(newTex); ``` OOHHH. I see. Using typescript and if the first parameter for the Texture class is not a base texture, I get a warning so I never bothered to try it. 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.