13,070

Views

Beginner

Level

2

Comments

Mobile Features (Keyboard & More)

by Jon (Updated on 2015-10-14)


Contents

  • Keyboard
  • Alerts
  • Vibrate
  • Other Features

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.

  • Set the keyboard's current text.
  • Clear the keyboard's text.

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:

  • Local Notifications
  • Web Views
  • Alternative Ad Networks
  • Rate My Game
  • Online Video Playback

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).

Print Article Edit Article How to Edit an Article
Disclaimer: Use comments to provide feedback and point out issues with the article (typo, wrong info, etc.). If you're seeking help for your game, please ask a question on the forums. Thanks!

2 Comments

Jon
Android soft keyboard is now available in 3.4.0 (Beta 2).
0 1 year, 10 months ago
grayfoxxkyle
when will there be an android version of "keyboard" ?
1 3 years, 2 months ago

Sign In to Comment