Mobile Features (Keyboard & More)

by Jon (Updated on 2015-10-14)


Contents

Keyboard

At times, it’s useful to display the on-screen keyboard in order to support text entry. For example, you may want the player to enter in a name when upon achieving a high score.

On Screen Keyboard

Showing/Hiding the Keyboard

Use the show keyboard block under User Input > Mobile to show or hide the Keyboard. When you do this, the keyboard will immediately display.

Show Keyboard block

Keyboard Events (knowing what's been typed)

Pressing the keys will fire keyboard events, which you can pick up on using a keyboard event (Add Event > Mobile > Keyboard). Each event will receive the complete text typed in so far, not the individual letters.

For example, you can record the currently typed in text and store that in an attribute...

Key Input

So that you can then draw it on screen.

Key Input

When the user’s done (hits return), you can get the final result and act accordingly.

Key Input

Other Operations

Besides receiving events, you can perform a few operations on the keyboard.

Alerts

Alerts are modal dialogs that display information to the user. When they appear, everything about the game pauses. Alerts are a blunt way of grabbing the user’s attention and should be used sparingly.

Alerts

To display an Alert, use the alert block at the bottom of Game > Mobile.

Display Alert block

Vibrate

Vibrations provide haptic (tactile) feedback to a user, if a device supports them. To vibrate a device, use the vibrate block at the bottom of User Input > Mobile-Only.

Vibrate

Notes: If a device doesn’t support vibrate (iPad, iPod Touch), nothing will happen. iOS devices may only vibrate for 2 seconds. In other words, you have no control over the duration.

Other Features

Stencyl supports additional mobile features through user-created extensions. These currently include:

Extensions found in our Extensions Market and our Extensions forum.

As these extensions mature and see further uptake, we'll selectively pull them into the core engine.

Want to create your own extension?

If you wish to contribute an extension you have a some technical expertise, consider creating a Extension which allows you to extend the Stencyl engine with native code (Objective-C, C++, Java).