I’m new to rpg maker mv and I’m wondering how I can create a little clicker minigame during combat. When casting a skill, I want to have a little minigame where the player have to quickly click circles that would show up in random positions on the screen and base on how well they did, the skill would get a damage buff or fail to cast
You’ll mainly be working with the TouchInput.isTriggered() function and
TouchInput.x and TouchInput.y to evaluate where or what the player clicked.
I would do this in a common event. I’m assuming you’re going to use Show/Move Picture commands for your circles. You’ll basically make a Conditional Branch that evaluates if the player has clicked or touched the screen and if that falls within the image’s hitbox.
The hitbox detections is easier done than explained.
Skill Setup
First, you’ll make a skill that calls a common event as an effect. Besides targeting an enemy, it doesn’t actually do anything. The Common Event will Show/Move your Circles and handle the detection, I’ll come back to that.
You’ll end the common event with the [Force Action] command, using the skill that does the actually animation and damage formula to the enemy.
The thing with [Force Action] in MV is that you can select “Last Target”, but the editor doesn’t provide a “Last Subject” in the drop down list. Maybe that’s not a problem if it’s a Harold Only skill, you just make Harold the subject. But if it’s a skill that any of the actors can use it’s easier to use the Force Action command via a script call and input the active battler as the subject.
//Force Action
this._params = [1, BattleManager._subject._actorId, 12, -2];
this.command339();
This is just an example script block that you’d use.
The parameters above translate to something like
[is an Actor, Active Subject Id, Skill ID, Last Target]
If you copy and paste it then all you need to change is the Skill ID number where I was using “12”.
Hit Detection
In the skill’s common event, you’re going to show/move your pictures around however you want. And run a conditional branch in a loop or as a secondary common event to detect the mouse clicks.
This is easier done than explained.
MZ would make this slightly easier than MV, because it has a clickable sprite class, but even those are still just rectangular hitboxes using the image’s frame. Since you’re using Circles, you’ll want to ignore the Alpha (transparent) pixels too, ideally. Luckily, MV has a getAlphaPixel() function we can utilize.
I put together this function pictureMouseover() for you. I started to explain how it works; but to keep this short, all you need to do is copy it in above your condition branch.
I had to make the format compact because MV’s Script box has limited vertical space ![]()
pictureMouseOver = function(picId) {
var pic = SceneManager._scene._spriteset._pictureContainer.children[picId - 1];
if (!pic || !pic.bitmap || !pic.bitmap.isReady()) return false;
var x = TouchInput.x, y = TouchInput.y, node = pic;
while (node) { x -= node.x; y -= node.y; node = node.parent; }
var bx = Math.floor(x / pic.scale.x + pic.bitmap.width * pic.anchor.x);
var by = Math.floor(y / pic.scale.y + pic.bitmap.height * pic.anchor.y);
if (bx < 0 || by < 0 || bx >= pic.bitmap.width || by >= pic.bitmap.height) return false;
return pic.bitmap.getAlphaPixel(bx, by) > 0;
};
Then use the function in your conditional branch like:
TouchInput.isTriggered() && pictureMouseOver(1)
This is evaluating true or false. If the player is touching/clicking something AND it’s over picture “1”. Meeting those conditions, it does whatever you want it to do.
The common event doesn’t look like much. Although I was just using a static picture. When you click on the picture, It plays a chime, erases the picture, and forces the action.
I have the Conditional Branch Script in a loop until the picture is clicked.
But for a timed event, you could break the loop with a switch from a secondary common event that manages your Circles.