How to fill a window with color?

Isabella Ava

Veteran
Veteran
Joined
Sep 13, 2016
Messages
635
Reaction score
756
First Language
English
Hi everyone,
I have add an custom window on map, i wonder how to fill it with a solid color and hide the window skin?
(so only a colored rectangle are showing instead of a window filled with color)
=D thank you very much
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,729
Reaction score
4,682
First Language
English
Primarily Uses
RMMZ
Hide the window skin with this (insert it in the window initialize process):
Code:
this.opacity = 0;
To draw a colored rectangle, use this code and insert it in the refresh method, after the content clearing line:
Code:
this.contents.fillRect(x, y, width, height, color);

// x: starting x position of the rectangle
// y: starting y position of the rectangle
// width: rectangle total width.
// height: rectangle total height.
// color: rectangle color. Use this format: "rgba(r, g, b, a)"
// - red, green and blue: value between 0 and 255
// - alpha: value between 0 and 1 (accepts decimal)
 

Isabella Ava

Veteran
Veteran
Joined
Sep 13, 2016
Messages
635
Reaction score
756
First Language
English
Hide the window skin with this (insert it in the window initialize process):
Code:
this.opacity = 0;
To draw a colored rectangle, use this code and insert it in the refresh method, after the content clearing line:
Code:
this.contents.fillRect(x, y, width, height, color);

// x: starting x position of the rectangle
// y: starting y position of the rectangle
// width: rectangle total width.
// height: rectangle total height.
// color: rectangle color. Use this format: "rgba(r, g, b, a)"
// - red, green and blue: value between 0 and 255
// - alpha: value between 0 and 1 (accepts decimal)
Thank you, i did that but it didn't work (i didn't fillRect in refresh method but only once at initialize metod though)
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,729
Reaction score
4,682
First Language
English
Primarily Uses
RMMZ
You probably try to use it before creating the content. Can you show your custom window's code?
 

Isabella Ava

Veteran
Veteran
Joined
Sep 13, 2016
Messages
635
Reaction score
756
First Language
English
You probably try to use it before creating the content. Can you show your custom window's code?
yes, i did it like this ( i tried with rgba() too) but it just doesn't work
Code:
this._cWindow = new My_Window(xx,yy);
            this._cWindow.opacity = 155;
            this._cWindow.contents.fillRect(0, 0, 5, 5, '#ff00a8');
            this.addChild(this._cWindow);
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,729
Reaction score
4,682
First Language
English
Primarily Uses
RMMZ
Did you put the "" around the rgba()? Like: "rgba(255, 255, 0, 1)"

If it still doesn't work, can you copy/paste your code for the My_Window object?
 

Isabella Ava

Veteran
Veteran
Joined
Sep 13, 2016
Messages
635
Reaction score
756
First Language
English
Did you put the "" around the rgba()? Like: "rgba(255, 255, 0, 1)"

If it still doesn't work, can you copy/paste your code for the My_Window object?
Yes, thank you very much for helping me = D
Probably i created too small windows but ..
Code:
function My_Window() {
    this.initialize.apply(this, arguments);
}

My_Window.prototype = Object.create(Window_Base.prototype);
My_Window.prototype.constructor = My_Window;

My_Window.prototype.initialize = function(x,y) {
    Window_Base.prototype.initialize.call(this,x,y,5,5);
}
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,729
Reaction score
4,682
First Language
English
Primarily Uses
RMMZ
Yeah, the content isn't being created because your window is too small. It needs to be more than 36 in both width and height.

By default, the content starts 18 pixel off every edge, making the window's content in reality 36 pixels less in width and height than the window itself.

this.contents.fillRect draws a rectangle, but insides the content, which in this case wasn't create due to having negative width and height value. So it couldn't draw anything.

The solution would be to have a window bigger than 36, and remove 18 from the x and y axis to draw your rectangle at the position you want:
Window_Base.prototype.call(this, x - 18, y - 18, 41, 41);
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,072
Members
137,578
Latest member
JamesLightning
Top