[RMMV] BITMAP.RESIZE() DOES NOTHING. HOW DO I SCALE A BITMAP?
Posts
Pages:
1
I've been trying to get a picture drawn at 200x200 pixels. So I wrote this code:
Yet it draws the pic at the exact same size it does without the resize() call. I'm confused ^^; How should I go about rescaling an image?
If it helps, I'm using RMMV version 1.5.1
let testBitmap = ImageManager.loadPicture("Sword"); // Original size: 816x624
testBitmap.resize(200, 200);
let testSprite = new Sprite(testBitmap);
this.addChild(testSprite);Yet it draws the pic at the exact same size it does without the resize() call. I'm confused ^^; How should I go about rescaling an image?
If it helps, I'm using RMMV version 1.5.1
Thanks to someone named MinusGix, I've figured it out. The reason it didn't work, was because the resize() function does nothing when the bitmap isn't done loading. Since bitmaps are loaded asynchronously, and I tried to resize it too fast, nothing happened.
After getting the resize to proc when the bitmap was done loading, I got an error because I tried to shrink the image. Apparently, the resize() func doesn't like shrinking.
Eventually, I found the solution in the Pixi API. I just had to:
1. Load the bitmap like before
2. Make a Pixi Sprite using that bitmap's base texture
3. Set the sprite's height and width
4. Add the sprite as a child to the window
Did that with the following code, and I got what I wanted.
No need to wait for the bitmap to finish loading; the base texture is ready immediately. ^_^
After getting the resize to proc when the bitmap was done loading, I got an error because I tried to shrink the image. Apparently, the resize() func doesn't like shrinking.
Eventually, I found the solution in the Pixi API. I just had to:
1. Load the bitmap like before
2. Make a Pixi Sprite using that bitmap's base texture
3. Set the sprite's height and width
4. Add the sprite as a child to the window
Did that with the following code, and I got what I wanted.
let testBitmap = ImageManager.loadPicture("Sword");
let pixiSprite = PIXI.Sprite.from(testBitmap.baseTexture);
pixiSprite.width = 200;
pixiSprite.height = 200;
this.addChild(pixiSprite);No need to wait for the bitmap to finish loading; the base texture is ready immediately. ^_^
Pages:
1













