It's been a while since I started coding for RPG Maker MV in javascript, but I have to confess that I'm still a bit better in RGSS (3 mostly). Although I've been able to code almost everything I wanted, there's a little something that bugs me: what's the equivalent of the rgss' viewport in javascript?
More specifically, I just need to make a sprite draw inside a certain viewport (rectangular). I scale and move the sprite constantly, but it must stay inside a rectangle. In RGSS you would just set a viewport with limits, and make that the sprite's viewport and voila. In MV I tried many stuff witout success:
1) Creating a sprite and setting the frame as the limit, and addChild my other sprite in it.
2) Same but with a window as the container.
Any solutions?
Equivalent of rgss viewport in javascript?
● ARCHIVED · READ-ONLY
-
-
I'd use PIXI mask for viewport, it's simple enough. You can use my diy series tutorial for that if you want.
-
Thanks! Works perfectly!
-
Oh and I forgot!
If you intend to create a sprite from a spritesheet, you can create a pixi texture from the spritesheet:
Code:var baseTex = PIXI.Texture.fromImage("img/Characters/People1.png"); var charTex = new PIXI.Texture (baseTex, new PIXI.Rectangle(baseTex, new PIXI.Rectangle(x,y,width,height)); var spr = new PIXI.Sprite(charTex);
However, this will save the base texture to pixi texture cache. What hasn't been said and what is difficult to find is, the textures have to be destroyed manually in order to free them from the gpu memory. -
@Poryg Alright thanks! Good to know!