MV bounch or fadeIn/FadeOut icons

Hi all,

I made a plugin to help someone out and this works pretty much perfectly and smooth.

now while the there are icons, I want to know how to bounce or fadeout/in the icon.

the array in particular is as follows inside a variable: [[false, false],[false, false],[false, false]] and it loops
till x times.

while it can unlock, it shows true/false for most, and once for true/true values.
while the 2nd returns false, I found that icon to fade in and out or small bounce (or chooseable)

iconset I use through param has 3 icons [locked, unlocked, position] )[0][1][2].

how can I fadein/out that position icon only or let it bounce smoothly?

the grid is made in a selection window because it can scroll as well, and I disabled (visibility).

this is the last function I want to add to make this plugin.
I want to know how to bounce or fadeout/in the icon.
You would update that icon's opacity every frame, e.g. via an appropriate update function.
  • If you've blitted the icon, e.g. to a window's contents bitmap, then that would mean:
    • Clearing the icon's area;
    • Setting the target bitmap's paintOpacity;
    • Blitting the icon to the newly-cleared area; then
    • Resetting the paintOpacity value.

  • If it's an independent sprite, then you can just update that sprite's opacity value.
its blt function to call the icons (3 icons in a row), so its called the
3rd icon.

and I try a few ways, but I tried in a simplify way.
JavaScript:
let opacity = 0;
if (opacity < 1) {
    opacity += 0.05
    this.contents.opacity = opacity
}

but it did nothing, with the console log, it output it once.
when using a while loop, it did 2x printing a 1.

but a simple while loop 0 to 300 did it once, but if I reverse it.
it freezes up.

but I need to look into the paintOpacity and how I could clear it.
do you have a rough sample?
You're most likely going to have an easier time of it by creating the icons as standalone sprites. It's way easier to write a bounce or fade routine for a sprite class, then let the window call that as needed, e.g. this._customSprite.startBounce()or something like this.customSprites()[0].startBounce()if you are using a container array to store the sprites.

In either approach (via updating a window's contents or a single sprite), you should be hooking theupdate()method which fires every frame, rather than creating some kind of arbitrary loop e.g. 0 to 300.
You're most likely going to have an easier time of it by creating the icons as standalone sprites.
I could try, but its only 3 that read the icons like "\\c[0]" ([1] and [2] to show them.
so I only need to target the last one.

the bounce there might be able to use y offset to -10 to 5 (base center) and back up.
but this leave the fading in/out a different story.

I mess around with bounce part, but dont get the fade, still failing.

as there are also changePaintOpacity that turn it false, than fill rect, and than true.
not sure how this exactly works either.
a simple while loop 0 to 300
No. Patch Your_Window.prototype.update for per-frame updates.
I need to look into the paintOpacity and how I could clear it.
  • this.contents.paintOpacity = 255; (rpg_core.js);
  • this.contents.clearRect(x, y, w, h); (rpg_windows.js).
paintopacity does everything which I don't want, I get it nowhere working.
as it seems cool.

I had another idea to use the pause sign, but unsure if that works in a selectable
window, as it could use that sign there and/or cursor with a different window skin.

changing window skin and change those 2 could work.
but than I need something to stop keypresses from changing locations and
stays on the XY position while scrolling (mouse wheel or pagedown/up).

I could block input to change those, so only X button works.

if that way is easier, maybe that route is better as it has 2 in 1.
255 opacity is opaque. So, for example, 128 opacity is ~50% transparent. I'm mentioning this because your earlier example tries to set opacity to 0.05.

Kenen and I have assumed you want an effect like "fade the icon's opacity from 0 to 255 over 15 frames", i.e. "+17 opacity per frame". If you actually just want to draw some selectable items in the window as "disabled" or "dim", then you can just set the opacity before and after in the selectable window's drawItem method, e.g.
JavaScript:
const isOpaque = index > 0;  // first item dim
this.changePaintOpacity(isOpaque);
// your draw code here
this.changePaintOpacity(true);

With that said, I've been having difficulty understanding most of your posts in this thread, even with context...so I'll let someone else help out. Good luck! 👋
With that said, I've been having difficulty understanding most of your posts in this thread
here is a sample (which I made a sprite cursor for it), not the perfect approach
SDJB_GridMapScene but when I target just the 3rd icon, with Y offset, it works.

using that to animate is what I struggle with, as it might go far easier if I can just
target the Y and make a switch selection to bounce or fade out, so it has a single
png.

for now, it can be choses between the 2, leave empty on 3rd icon so you can use
a sprite one instead of any frames, but I hope I can get rid of it.

the code above with opacity just target all, and I need to mess around with it.
how to update this clean, so it does it work clean and effeciently.

so I leave it how it is, the code is open, so you see how I did it.
but if there is a cleaner way, I'm open to learn it.

Original thread: https://forums.rpgmakerweb.com/threads/bounch-or-fadein-fadeout-icons.176590/