-
Notifications
You must be signed in to change notification settings - Fork 0
/
bentelk_ThisIsntADanceParty.js
41 lines (36 loc) · 1.37 KB
/
bentelk_ThisIsntADanceParty.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*:
* @plugindesc Gives greater control over the cursor blink.
* @author Ben Hendel-Doying
*
* @help
* It also uses a sine wave to control the opacity, rather than linearly
* bouncing between its maximum and minimum opacity levels.
*
* Default settings create a slower pulse over a narrower range of opacity
* levels.
*
* You can customize the speed of the pulse, and minimum and maximum levels of
* opacity, by editing this plugin. Don't be afraid! It's easy! The values to
* change are clearly labeled, and near the top of the file.
*/
Window.CURSOR_FRAME_COUNT = 60; // higher number = slower pulse
Window.CURSOR_MAX_OPACITY = 224;
Window.CURSOR_MIN_OPACITY = 96;
Window.CURSOR_INACTIVE_OPACITY = 160;
// edit only if you're adventurous and/or know JavaScript
Window.prototype._updateCursor = function()
{
if (this.active)
{
let blinkCount = this._animationCount % Window.CURSOR_FRAME_COUNT;
let wave = Math.cos(blinkCount * 2 * Math.PI / Window.CURSOR_FRAME_COUNT);
let opacityRange = Window.CURSOR_MAX_OPACITY - Window.CURSOR_MIN_OPACITY;
let cursorOpacity = Window.CURSOR_MAX_OPACITY - (wave + 1) / 2 * opacityRange;
this._windowCursorSprite.alpha = cursorOpacity / 255;
}
else
{
this._windowCursorSprite.alpha = Window.CURSOR_INACTIVE_OPACITY / 255;
}
this._windowCursorSprite.visible = this.isOpen();
};