Manual: Supporting touch controls with the virtual pad (virtual gamepad)

About this manual

This manual explains how to use the virtual pad in ACTION GAME MAKER. The virtual pad lets games exported to iOS / Android be played with on-screen buttons and sticks. It also covers how to create a virtual pad and place its parts, how to use groups to keep buttons in a corner of the screen, and how to use a stick for aiming and changing direction.

What the virtual pad can do

The parts of a virtual pad act as if the project’s input actions (up, A and so on) were pressed. This is treated the same as pressing them on a keyboard or gamepad, so your existing visual script input conditions and movement settings work with touch as they are, without any changes.

What you want How the virtual pad handles it
Move with a stick A “Virtual Pad Stick” presses the up, down, left and right actions. How far you pull it also changes the speed of analog movement
Jump or attack with a button A “Virtual Pad Button” presses the action you set (A and so on)
Jump while moving Several fingers can be used at the same time
Hold down a dash or similar Set the button mode to “Toggle”, and each tap switches between held and released
Aim or set the direction with a stick “Gamepad Stick” lets the stick be treated as the left or right stick
Fire bullets toward where you tap Tapping outside the virtual pad works as the mouse
Hide the pad during conversations or movies Switch it with the visual script action “Show Virtual Pad”
Two players sharing one device Each part has its own “Player” setting (1P to 8P)

There are two kinds of part.

Name in the add menu Class Behaviour
Virtual Pad Button VirtualPadButton Presses an action only while touched (Push). Can also be a toggle
Virtual Pad Stick VirtualPadStick Presses the up, down, left and right actions with a strength based on how far and in which direction you pull from where you touched

Preparing a virtual pad

A project has its virtual pad as a single scene. When the game runs, that scene stays in front of the game screen. It does not disappear on scene transitions or when menu scenes open and close.

There are two ways to create one. Both create it with the default layout: a stick at the bottom left and B and A buttons at the bottom right.

Creating it in the map editing view

  1. In the “Maps” list in the left column, press “+ Create New”.
  2. Choose “Virtual Pad” as the kind, give it a name and create it.
  3. The new virtual pad opens. If the project has no virtual pad set yet, it is also set automatically as the virtual pad used in the game.

Creating it from Basic Settings

  1. Open “Basic Settings”.
  2. Under “Virtual Pad”, press “Create with Default Layout”.
  3. The location of the new scene is shown, and it is set as the virtual pad used in the game.

The virtual pad scene and the button images are placed in res://virtualpads.

The virtual pad used in the game and when it is shown

Under “Virtual Pad” in “Basic Settings”, choose these two settings.

Setting Description
Scene Path Choose the virtual pad used in the game from the list of virtual pads in the project. With “Not Set”, no virtual pad appears
Display Touch Devices Only (default) / Always Shown / Hidden

With “Touch Devices Only”, the pad does not appear when playing on a PC. To try the controls in a PC test play, choose “Always Shown”. The mouse then works in place of touch (as a single finger).

Placing parts

When you open a virtual pad, a “Virtual Pad Settings” row appears at the top of the Map Layers dock. Add parts with the “+” (Add Element) button on this row, or on the row of a group (described below).

Element Used for
Virtual Pad Button A button that presses an action
Virtual Pad Stick A stick that presses up, down, left and right
Group A frame that gathers parts and keeps them in a corner of the screen
Image Decorative images
Label Text placed on a button, for example

A newly added button is placed with a round image and the action A. A stick is placed at a size of 260×260.

Keeping parts in a corner with groups

Virtual pad buttons are shown at the position (coordinates) they are placed at. They do not follow the “bottom right” when the screen size or aspect ratio changes. To keep them in a corner even though screen ratios differ from device to device, use a group.

  1. Add a “Group” from “+”.
  2. In the group’s “Layout”, choose “Bottom Right” or similar under “Anchors Preset”.
  3. Add buttons from “+” on the group’s row (or drag and drop buttons onto the group’s row to put them inside).
  4. A button’s “Position” is now its position inside the group.

The default layout is built this way.

Virtual Pad Settings (VirtualPadScene)

├ LeftBottom (group, bottom left)

│ └ Stick (Virtual Pad Stick)

└ RightBottom (group, bottom right)

├ ButtonB (Virtual Pad Button)

│ └ Label "B"

└ ButtonA (Virtual Pad Button)

└ Label "A"

Groups do not take touches, so even if a group is larger than its buttons, it does not get in the way of the parts behind it or of the game screen.

The virtual pad is automatically moved inward so that it stays clear of the “safe area” — notches, the home indicator and so on. Even if you place parts right at the edge of the screen, they will not be hidden behind a notch.

Button settings

Select a button, and the Inspector shows these settings (they appear without opening “Advanced Settings”).

Setting Description
Player Which player’s input the button presses as (1P to 8P, default 1P)
Button Mode Push (presses only while touched) / Toggle (each tap switches between held and released)
Texture Normal / Texture Pressed The look of the button. While pressed (or toggled on), the pressed image is used
Action The input action to press (A, B, start and so on)
Shape / Bitmask The shape that counts as a touch. If not set, the image’s rectangle is used
Passby Press When on, the button is also pressed when a finger slides onto it from elsewhere

A button’s size is decided by its image. To change the size, scale it up or down with “Scale”, or set an image of a different size.

To show text on a button, put a label as a child of the button, as in the default layout. Right-click a button in the default layout and choose “Duplicate” (Ctrl+D) to copy it together with its label.

When to use Toggle

Use Toggle when you want an action that works while “held down”, such as a dash or a crouch, to continue after you lift your finger. Tap again to release it. When the virtual pad is hidden (during loading and so on), toggles are released automatically.

Stick settings

Select a stick, and the Inspector shows these settings.

Setting Description
Player Which player’s input the stick presses as (1P to 8P, default 1P)
Gamepad Stick None / Left Stick (default) / Right Stick. Used for aiming and changing direction (see below)
Base Texture / Base Texture Pressed The look of the stick’s base (the outer circle)
Tip Texture / Tip Texture Pressed The look of the tip you move with your finger. If no pressed image is set, the normal image is used
Joystick Mode Fixed (always in the same place) / Dynamic (appears where you touch) / Following (the base follows when you move your finger far)
Joystick Size / Tip Size The size of the base and the tip
Deadzone Ratio Up to this ratio from the centre counts as no input
Clampzone Ratio Pulling this ratio from the centre gives the maximum input
Action Up / Down / Left / Right The input actions to press (default up / down / left / right)
Visibility Mode Always / When Touched (shown only while touched)

With “Dynamic” or “Following”, the area the stick responds to is the stick’s own rectangle. To accept touches over a wide area at the bottom left, make the stick larger (the default layout stretches it to fill the bottom-left group).

The stick presses the up, down, left and right actions with a strength based on how far it is pulled. Analog and free-angle movement in the movement settings, and stick input conditions, respond as they are.

Aiming and setting the direction with a stick

Aiming and throwing directions for bullets, and the “Stick” option of “Change Angle”, read the gamepad stick directly rather than the up, down, left and right actions. “Gamepad Stick” makes the virtual pad stick work here too.

  • With the default “Left Stick”, the direction of the stick used for movement is also used as the left stick for aiming and so on.
  • When a real gamepad is connected, whichever is tilted further is used.

To move with the left stick and aim with the right (twin-stick), do the following.

  1. Add a second stick, at the bottom right for example.
  2. Make all of the new stick’s “Action Up / Down / Left / Right” empty (it is not used for movement).
  3. Set “Gamepad Stick” to “Right Stick”.
  4. Set aiming or “Change Angle” to use the right stick.

Touches outside the virtual pad (in place of the mouse)

While the virtual pad is shown, a touch from a finger that is not on a virtual pad part works as the mouse. Features that read the mouse position and left click (mouse input conditions, getting the mouse position, aiming at the mouse position, moving objects with the mouse and so on) run on that touch.

  • If you hold the stick and tap the screen with another finger, the tapped position becomes the mouse position.
  • A finger that started pressing on a part belongs to that part until it is lifted. Pressing a button does not move the mouse position onto the button, and does not count as a left click.

This lets you build controls such as “move with the stick while shooting toward where you tap”.

Switching the display from a visual script

The action “Show Virtual Pad (ShowVirtualPad)” (category “Game Settings”) shows or hides the virtual pad.

Setting Description
Pad Visible On to show, off to hide
  • It is intended for hiding the pad during conversations and movies, and showing it again afterwards.
  • The hidden state continues across scene transitions. To bring it back, show it again with this action.
  • It does nothing if the project has no virtual pad, or if the pad is not shown because of the display setting (“Touch Devices Only” on a PC and so on).

When the pad is shown

Situation Virtual pad
During the game, and while menu scenes are open Shown (in front of menus)
While the game is paused Shown, and can be operated
Loading scenes, fades, the startup splash Hidden
After hiding it with “Show Virtual Pad” Hidden (even after scene transitions)

Notes

  • Virtual pad buttons do not stay in a corner through “anchors”. To keep them in a corner when the screen ratio changes, put them in a group and set the group’s anchors.
  • A button can press only one action. You cannot make a button that presses A and B together, or a diagonal button.
  • Parts cannot be shown or hidden individually. A visual script can only switch the display of the whole virtual pad.
  • To try it in a PC test play, set “Display” to “Always Shown”. With “Touch Devices Only”, it does not appear on a PC. Remember to set it back before exporting.
  • The mouse stands in for only one finger, so on a PC you cannot try simultaneous controls such as “jump while moving”. Try simultaneous controls on a real device or a simulator.
  • The virtual pad can be used together with a keyboard or gamepad. An action counts as “pressed” if either one is pressing it.
  • The root of a virtual pad scene must be a “Virtual Pad Scene” (VirtualPadScene). Scenes created from the map list or Basic Settings are made this way. Scenes whose root is a different kind do not appear in the lists in the map list or Basic Settings.