Transforming Bitmaps

I'd like to make some simple animations using bitmaps like gently going up and down the y axis to simulate floating, rotating 360 degrees or scaling up and down.

(Sorry if its bad etiquette to make a new thread, if I should have continued in the original please combine them)
Talking about sprites or bitmap in general, like the content of a window? For sprites it's really easy: change the x and y position. For example the update function is called once per frame, so if you do x+1 in that function, the sprite will move 1 pixel every frame, creating a little animation of moving right.
Ah I think I get it, and I could use conditionals to send it back, how about things like scale and rotate? And yes this for sprites in a window.
There's a property called "rotation" for sprites and it is in radiant. Another one is called "scale":

Code:
var sprt = new Sprite();

sprt.bitmap = ImageManager.loadPictures("exampleOfPicture");
sprt.rotation = Math.PI(); // Sets the rotation to 180 degree.
sprt.scale.x = 1.5; // Sets X scale to 150%
sprt.scale.y = 1.5; // Sets Y scale to 150%

Honestly there's a limit to what you can do with the default code of RPG Maker. If you just want to stick to scaling stuff, rotate a bit stuff, that's fine. If you want to do more stuff, I highly suggest you learn about the PIXI library which is included in RPG Maker. PIXI is very powerful and versatile and isn't that complex to learn. I think @Poryg has some tutorials on how to play with PIXI.
I'm not a Pixie of the Emvee kingdom for naught after all 😀

Anyway, it's not just my tutorials.
There's also several other important things that can show you something that can be done with pixi.
demo
https://pixijs.io/examples/#/basics/basic.js
documentation
http://pixijs.download/dev/docs/index.html
PIXI filters (only few of them are in basic pixi.js, the rest require pixi-filters.js
https://pixijs.io/pixi-filters/tools/demo/
Before I looked into pixi I wanted to see what I could pull off default, I got a good floating animation and I've been trying to use scale to do breathing but the sprite's origin is always upper left so it can only grow downwards it seems, is there a way to change it?
You can change the sprite's anchor to 0.5 (on x and y).

Or do it it the hard and silly way like I did (cause I didn't know about the anchor property at the time): every I updated the scale first for the breathing effect, then a readjusted the position based on the scale (so it would move to give the effect it isn't moving).

But yeah, just set the anchor to 0.5 lol. That way it will treat the center of the sprite as the center.
Alright so I ended up settling on anchor 1.1, and the animation looks right the only problem is that the mouseover script you showed me before is a bit funky now (I'll just stick to this thread). hovering over the empty area to the bottom right of the sprite triggers the hover effect now, I'm guessing I need to reverse the script? I tried messing with it but cant figure it out.

Code:
if (a.x >= b.x && a.x <= (b.x + b.width) ) { // check the x condition
    if (a.y >= b.y && a.y <= (b.y + b.height) ) { // check the y condition
        return true;
    }
}
Playing with anchor after playing with position will screw over all your work with position. When you set the anchor, you set the origin point of a sprite to that anchor. If the anchor.x = 0.5, that means that when you set the x of the sprite, you set the middle of the sprite to the x position.

Btw, anchor is a value between 0 and 1:
- 0: Refers to the extreme left for the x, and the top of the sprite for the y.
- 1: Refers to the extreme right for the x, and the bottom of the sprite for the y.
- Values in between refer the ratio of the width/height. If a sprite's width is 100, anchor.x = 0.5 will set the pixel 50 as the center.

So you understand the problem now. When you call the a.x and the a.y, you're calling the position at the anchor point of the sprite and not the top left corner of the sprite, like the original code was intended to do. So to fix the problem you have to take into account the x and y position of the top left corner, not the anchor point:

Code:
var real_x = a.x - a.anchor.x * a.width;
var real_y = a.y - a.anchor.y * a.height;

// Then the same as before, just replace a.x by real_x and a.y by real_y
// Note that I have not tested, and it is only based on the theory lol.
Worked perfect, thanks again, just one last question for now, The structure of the menu I'm building is supposed to cut out the tedium of the actor select while still supporting a party, How do i force set the actor before loading personal scenes like status/equip? like having a single command push the next scene and set the actor at the same time without select.
So you want to eliminate the character selection after selecting status and equip, and have the player switch actors directly in the status or equip scene? For that you'll need to rework the logic of the default menu scene.

In the default menu, when you select the status command, the skill command, or the equip command, it will automatically call a function called "Scene_Menu.prototype.commandPersonnal" (every handler for every command are set in the function Scene_Menu.prototype.createCommandWindow). You'll need to change the handler function for these commands, and make it so selecting status, skill, or equip will instead lead directly to the next scene (menu status, menu skill, or menu equip). I think it is already possible to switch between actors in those scenes, although not sure since I haven't use the default menu for many years.
Well the way i have it set up now is the main menu displays portraits of all the actors, I'd like to have it so when you click one you create a few buttons which will lead directly to the actors skill/status/equip. The aim is full mouse controlled UI that feels natural.

Like this:
e8XrGGz.png


So a single click would both set the actor and push the scene at once.
Not sure how far off I am but i tried this but it kills the plugin,
Code:
this._actorbutton.setClickHandler($gameParty.menuActor() = $gameParty.members()[0]._actorId; this.SceneManager.push(Scene_Status));
Whats the correct way?
Couple of things:
- The "setClickHandler" function accepts one parameter, which is a binded function.
- The "menuActor" for the Game Party object is a getter function, not a setter.
- You're accessing the actorId the wrong way. It will work the way you did it but it's against conventions (it's because it would be bad programming in C++/C# to first of all create an "Id" property as a global variable. You would usually create it as a private variable and use a setter and getter method to get its value and set its value).
- The way you have it set up, you want it to always set the menuActor the the actorId of the first party member?
- No need to put "this" in front of "SceneManager" since SceneManager is not a property/function of Scene Menu.

Anyways, here is how I would do it (although I don't know how you coded the actorButton object and how you get the party member id from that object):

Code:
Scene_Menu.prototype.createActorButton = function() {
    // where you created your actor button, but again I don't know how you coded that object.
    this._actorButton = new Sprite_ActorButton();
    this._actorButton.setClickHandler(this.commandActorButton.bind(this));
};

Scene_Menu.prototype.commandActorButton = function() {
    var actor = ??? // You need a way to determine the party Actor Id, basically which actor button has been pressed.
    $gameParty.setMenuActor(actor);
    SceneManager.push(scene); // Again, need a way to determine the scene, which comes back to how you coded your actor button object because the scene is determined by which button you pressed.
}

NOTE: If you're still in your early times of javascript, you might benefit from some online tutorial. Javascript is a weird language, but close to languages in the C family.
Alright I understand now, And yeah I might be moving too fast with this stuff, I kinda randomly dived in and then logic'd my way through by just copying existing functions and tweaking, I've been sticking to visual things like UI/HUD and adding parameters. The results are good though, the menus and controls now feel unique for a rpgmaker game.
I do regret skipping math during secondary education though 😅, I'll hit up those tutorials soon so I don't end up messing up on basics anymore, thanks for all the patience and help so far.
Nice! It's great to see people learning to code here.

Original thread: https://forums.rpgmakerweb.com/threads/transforming-bitmaps.105137/