29,144
Views
Beginner
Level
4
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.
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.
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...
So that you can then draw it on screen.
When the user’s done (hits return), you can get the final result and act accordingly.
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.
To display an Alert, use the alert block at the bottom of Game > Mobile.
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.
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