Ok so now I know it will since you've confirmed it but I'm still not sure why the this.opacity = 255; didn't effect the sprites when I set it to 0. It only made the rectangle invisible but not the contents, its not a concern if I can get it to work properly.
View attachment 250678
I don't see any attachment. I'd need to either see the error messages / screenshots or need the functional plugin with its plugin commands etc. so I can test it myself.
I thought prototypes were a rpgmaker thing. When little I learned using those learning apps in javascript I don't remember seeing anything on prototypes but classes, objects and functions yes. I will definitely study more.
No. Prototypes are an essential part of js and the backbone of how all objects work. When you create an Array, or an Object, it is build based on the Array and Object prototypes. Class is an easier way to create prototypes. Everything RPGMV/Z does inside the game is javascript.
Ok I understand what you're saying about how it changes it for all windows, but did I needed to add this entire function to my plugin or was it an example you used to try to explain to me what I was missing? Was I suppose to add this.updateOpen() and close to my Scene_Map.prototype.start function?
No, that was me showing you the original function your class is meant to inherit. You can include this entire function by simply using super.update(), as you're now correctly doing inside your function.
So what I took from this is that the class I made Window_ActorHUD extends WindowBase essentially updates 60 times a second....If so why would I even need the update(){super.update();}?
If it's attached to an object that updates its children (sprites, windows, scenes), yes.
You need the super.update() call to keep the function you see above existing and included in your update, because that function links further functions and has its own code which is crucial to keep a lot of the things a window can do alive.
The window you're extends another object to inherit its properties.
It's like buying a car and then adding another display & autoparking to it. But to do so, you cannot just rip out and remove all the electrics that kept the motor functioning, the displays going and allowed the entire car to work.
For instance, the Window_Base's update function contains the Window update function.
This is the Window update function:
This is the function that allows sprites attached to your window to also be updated, just like the scene updates your windows. If you override this function, you strip your new window of the ability to update & show any sprites or windows attached to it.
I did copy and pasted your example but the open close still doesn't work....This is the whole code:
Code:
//PLUGIN VARIABLES
const openWindow = Scene_Map.prototype.start;
let hudWidth = 200;
let hudHeight = 55;
const floor = Math.floor;
var newCharacterGraphic = '';
//WINDOW CONTAINERS
Scene_Map.prototype.start = function() {
openWindow.call(this);
//THIS FUNCTIONS VARIABLES
let x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? 0 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? Graphics.width-hudWidth : Graphics.width/2-hudWidth/2;
let y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? 0 : Graphics.height-hudHeight;
//WINDOW PARAMETERS
this.actorHud = new Window_ActorHUD(new Rectangle(x, y, hudWidth, hudHeight));
//OPACITY OF THE WINDOW BOXES
this.actorHud.opacity = 255;
//CREATES THE WINDOWS THE GRAPHICS ATTACH TO
this.addChildAt(this.actorHud,1);
}
//GRAPHICS
class Window_ActorHUD extends Window_Base {
//GRAPHICS/ANIMATIONS SETTINGS
constructor(rect) {
super(rect);
//LEFT/RIGHT BACKGROUND GRAPHIC POSITION
this.sidesBackground = new Sprite(ImageManager.loadPicture(LadyLegend.PlayerHud._HUDsb));
this.sidesBackground.anchor.set(0.5);
this.sidesBackground.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/1.5 :hudWidth-hudWidth/1.5;
this.sidesBackground.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
if(eval(LadyLegend.PlayerHud._HUDx) > hudWidth) this.sidesBackground.scale.x *= -1;
if(eval(LadyLegend.PlayerHud._HUDx) == '0' || LadyLegend.PlayerHud._HUDgx == Graphics.width) this.addChildAt(this.sidesBackground,1);
//CENTER BACKGROUND GRAPHIC POSITION
this.centerBackground = new Sprite(ImageManager.loadPicture(LadyLegend.PlayerHud._HUDcb));
this.centerBackground.anchor.set(0.5);
this.centerBackground.x = eval(LadyLegend.PlayerHud._HUDx)-hudWidth*1.45;
this.centerBackground.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
if(eval(LadyLegend.PlayerHud._HUDx) == Graphics.width/2)this.addChildAt(this.centerBackground,1);
//CHARACTER GRAPHIC POSITIONS
this.characterGraphic = new Sprite(ImageManager.loadPicture($gameParty.leader()._name));
this.characterGraphic.anchor.set(0.5);
this.characterGraphic.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/4.2 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? hudWidth-hudWidth/4.2: hudWidth/2 ;
this.characterGraphic.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0 ;
if(eval(LadyLegend.PlayerHud._HUDx) < hudWidth) this.characterGraphic.scale.x *= -1;
//ANIMATION FRAMES
if(LadyLegend.PlayerHud._HUDaf == 'true') {
this.animation = [
[0,0],
[1,0],
[2,0],
[1,0]
];
//ANIMATION SPEED SETTINGS
this.animationSpeed = 60/15;
this.tick = 0;
this.frame = 0;
}
else {
this.animation = [
[0,0],
]
this.animationSpeed = 60/15;
this.tick = 0;
this.frame = 0;
}
};
//CROP SIZE SETUP FOR ANIMATED GLOBAL GRAPHIC
async calcSize(width, height) {
return [
floor(64),
floor(64),
];
};
//ANIMATED GRAPHIC CROPPED AND DISPLAYED
setFrame(characterGraphic, x, y) {
this.calcSize(characterGraphic.bitmap.width, characterGraphic.bitmap.height).then(f => {
x *= f[0];
y *= f[1];
characterGraphic.setFrame(x, y, f[0], f[1]);
this.addChildAt(this.characterGraphic,3);
})
}
update() {
this.processOpenCloseButton();
super.update();
this.changeCharacterGraphics();
this.processAnimationTicks();
this.drawPartyLeaderStateIcon();
}
processOpenCloseButton() {
if(Input.isTriggered('ok')) {
if(this.isOpen()) {
this.close;
} else {
this.open;
}
}
}
changeCharacterGraphics() {
if (newCharacterGraphic != $gameParty.leader()._name) {
newCharacterGraphic = $gameParty.leader()._name;
this.removeChild(this.characterGraphic);
this.characterGraphic = new Sprite(ImageManager.loadPicture(newCharacterGraphic));
this.characterGraphic.anchor.set(0.5);
this.characterGraphic.x = eval(LadyLegend.PlayerHud._HUDx) == 0 ? hudWidth/4.2 : eval(LadyLegend.PlayerHud._HUDx) == Graphics.width ? hudWidth-hudWidth/4.2 : hudWidth/2;
this.characterGraphic.y = eval(LadyLegend.PlayerHud._HUDy) == 0 ? hudHeight : 0;
if(eval(LadyLegend.PlayerHud._HUDx) < hudWidth) this.characterGraphic.scale.x *= -1;
}
}
processAnimationTicks() {
this.tick+=this.animationSpeed;
if(this.tick>=60) {
this.tick=0
this.setFrame(this.characterGraphic, this.animation[this.frame][0], this.animation[this.frame][1]);
this.frame++;
if(this.frame>=this.animation.length) this.frame=0;
};
}
drawPartyLeaderStateIcon() {
if($gameParty.leader().states().length != 0) this.drawIcon($dataStates[$gameParty.leader()._states].iconIndex, eval(LadyLegend.PlayerHud._HUDix), eval(LadyLegend.PlayerHud._HUDiy));
}
}
I'd need the plugin file with the additional Plugin Settings to take a look. There's some stuff I don't know why you used it, and I'd have to check out what it causes to happen.
For instance, instead of addWindow(), you've used addChildAt()
but doing so doesn't add the window you've created to the window layer and I don't know why you've decided not to do so.
I also don't know what works, what's displayed, if you're -for example- loading sprites that require loadlisteners, etc.
I'd need screenshots, error messages, or the plugin code ready for me to test ingame.
I also don't know why you're removing and adding sprites here:
If you want to change the image that's shown, you can just leave the sprite be and update its bitmap texture.
e.g.
JavaScript:
changeCharacterGraphics() {
if (newCharacterGraphic != $gameParty.leader()._name) {
newCharacterGraphic = $gameParty.leader()._name;
const image = ImageManager.loadPicture(newCharacterGraphic);
this.characterGraphic.bitmap = image;
}
}
I did get the button to work by testing a switch but I remapped my core button for my personal project. For the most part I'm not trying to use many plugins or any at all from others is my ultimate goal because of that whole compatibility issue that halts not just my own but many peoples projects. So I thought I'd try my hand in it considering I'm a quick learner but I understand the problem if I want others to use the plugin which I do so I really only have one question about that. You know how the "ok" has like 3 buttons mapped to it(Z, Spacebar,Enter), how to I target the spacebar "ok" press?
You cannot, by default. The Input Check does not check what "ok" button is pressed, just that one of the three buttons is pressed.
If you don't care about compatibility and accept that this will invasivly affect other plugins and the default functionality, you could do this:
JavaScript:
Input.keyMapper[32] = "space";
at the start of your plugin.
This remaps the space key (code 32) away from ok and to a new keyword "space".
And then you can ise Input.isTriggered("space") to check if the spacebar is triggered.
This will prevent the spacebar from every working as an "ok" button, though.
Outside of my plugin, short of creating your own input system, that's the only way to be able to check for the spacebar.
The test didn't work and I tried to using an event to see if it would close my window both hide and close didn't work..
SceneManager._scene._Window_ActorHUD.hide()
I also tried it as a plugin command
View attachment 250682
I'm not sure what you're doing there?
Why are you using Window_ActorHud? I thought, according to your code, the window is stored as actorHud in the scene?