Set Flashing Animation | Mouse Press Plugin

Lloyd@RedIronLabs

Lloyd - RedIronLabs | LRHS | FileArchiveHaven
Member
Joined
Oct 7, 2017
Messages
4
Reaction score
10
First Language
en
Primarily Uses
RMMV
Howdy all - for RPG Maker MV v1.5

sam4.gif

Why
I picked up MV months ago, but decided to play with it today. I love it, but I didn't like the default square blinking effect on press. So, I thought I'd do the responsible thing and create a plugin to grant more options.

What
This lets you completely disable, and/or customize the blink effect when clicking or pressing.

Options

While messing around I chucked a bunch of options in there.

Color
Any CSS color including RGB and RGBA

Types
none, circle, square, box, url, text, circleoutline

Scale
0 to 1

Data
(optional) String or image URL to use

Animate
on or off, for the blink effect

BounceSpeed
Works inversely, I like 40, 60 or 90.​

Script:

License is do whatever you want (tm). Yes, you can use it commercially.

filename: SetFlashAnimation.js,
save in your projects js\plugins folder.

Code:
/*:
 * @plugindesc Sets, changes or removes the flashing press indicator.  v1.0
 * @author Lloyd (Red Iron Labs)
 *
 * @help This plugin does not provide plugin commands.
 *
 * @param color
 * @desc CSS color format of the bitmap.  RGB & RGBA allowed (i.e. rgba(0, 255, 0, 0.3)).
 * @default white
 *
 * @param settype
 * @desc none, circle, square, box, url, text, circleoutline
 * @default none
 *
 * @param scale
 * @desc scale from 0 to 1
 * @default 1
 *
 * @param data
 * @desc the text string (i.e. X) OR reference URL to an image to use (i.e. img/system/Shadow1.png)
 * @default img/system/Shadow1.png
 *
 * @param animate
 * @desc Bouncing animation
 * @default on
 *
 * @param bouncespeed
 * @desc Speed of bounce
 * @default 20
 *
 */

(function () {

    function toNumber(str, def) {
        return isNaN(str) ? def :  + (str || def);
    }

    var parameters = PluginManager.parameters('SetFlashAnimation');
    var color = parameters['color'].toLowerCase();
    var settype = parameters['settype'].toLowerCase();
    var scale = toNumber(parameters['scale'], 1);
    var data = parameters['data'];
    var animate = parameters['animate'].toLowerCase() == "on";
    var bouncespeed = toNumber(parameters['bouncespeed'], 20);

    Sprite_Destination.prototype.updateAnimation = function () {
        if (animate) {
            this._frameCount++;
            this._frameCount %= bouncespeed;
            this.opacity = (bouncespeed - this._frameCount) * 6;
            this.scale.x = 1 + this._frameCount / bouncespeed;
            this.scale.y = this.scale.x;
        }
    };

    Spriteset_Map.prototype.createDestination = function () {
        if (settype != 'none') {
            this._destinationSprite = new Sprite_Destination();
            this._destinationSprite.z = 9;
            this._tilemap.addChild(this._destinationSprite);
        }
    };

    Sprite_Destination.prototype.createBitmap = function () {

        var tileWidth = $gameMap.tileWidth();
        var tileHeight = $gameMap.tileHeight();
        this.bitmap = new Bitmap(tileWidth, tileHeight);

        if (settype == 'square' || settype == 'box') {
            this.bitmap.fillRect(
                (tileWidth - (tileWidth * scale)) / 2,
                (tileHeight - (tileHeight * scale)) / 2,
                tileWidth * scale,
                tileHeight * scale,
                color);
            if (settype == 'box') {
                this.bitmap.clearRect(
                    ((tileWidth - (tileWidth * scale)) / 2) + 4,
                    ((tileHeight - (tileHeight * scale)) / 2) + 4,
                    (tileWidth * scale) - 8,
                    (tileHeight * scale) - 8);
            }
        }

        if (settype == 'circle' || settype == 'circleoutline') {
            var minSize = tileWidth;
            if (tileHeight < tileWidth)
                minSize = tileHeight;
            this.bitmap.drawCircle(tileWidth / 2, tileHeight / 2, (minSize / 2) * scale, color);
            if (settype == 'circleoutline') {
                this.bitmap.drawCircle(tileWidth / 2, tileHeight / 2, ((minSize / 2) * scale) - 4, 'clear');
            }
        }

        if (settype == 'text') {
            this.bitmap.outlineColor = color;
            this.bitmap.drawText(
                data,
                (tileWidth - (tileWidth * scale)) / 2,
                (tileHeight - (tileHeight * scale)) / 2,
                tileWidth * scale,
                tileHeight * scale,
                'center');
            this.bitmap.blur();
        }

        if (settype == 'url') {
            this.bitmap = ImageManager.requestNormalBitmap(data, 0); // Bitmap.load(data);
            this.bitmap.resize(tileWidth, tileHeight);
        };

        this.anchor.x = 0.5;
        this.anchor.y = 0.5;
        this.blendMode = Graphics.BLEND_ADD;
    };

})();
Images:
img1.PNG
sam1.gif sam2.gifsam3.gif sam4.gif

Upcoming features:
None planned - but it is a pretty basic script. It isn't tested with other scripts, so could break stuff. In which case, just use it to learn if you like.
 

Attachments

Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

Managed to find a way to hang a bed cover over my window. So no more being toasted alive in the afternoon!:kaoswt2:
So, uh, has anyone tried buying any resources from KokoroReflections? Because I've been looking for a 'buy' button on the site for like 10 minutes now and can't find one.
Any also thought it's too cringy to put the word "and you" in your credit as a special thanks?
Cause that's what I thought...
Everyone in the US right now: Please stay safe.
Symphony Celestia: Prophecy of the Falling Stars RPG Maker music pack WIP. Symphony Celestia is a new series that focuses on symphonic and orchestrated music to tell a story. Each story will include compositions that make up that story from beginning to end. Themes include: Battles, adventures, character themes, etc. Below is a video preview to the first story.

Forum statistics

Threads
97,980
Messages
948,329
Members
129,246
Latest member
Flaminguex
Top