Username or E-mail
Password (Forgot?)
New? Sign Up
Join or Sign In
Forums Stencylpedia Stencyl TV Translations Go Pro - Plans & Pricing Download Stencyl


Switch to Book Layout

1: Getting Started

  • Getting Started
  • Crash Course
  • Crash Course 2
  • StencylForge

2: Building Logic

  • What is a Behavior?
  • Creating a Behavior
  • Attributes
  • Game Attributes
  • Attribute Types
  • Events
  • Our Behaviors

3: Actors

  • What are Actors?
  • Animations
  • Motion & Forces
  • Physics
  • Controls
  • Collisions & Groups
  • Killing vs. Recycling
  • Tweening
  • Effects
  • Chapter 3 Challenge

4: Scenes

  • Scene Basics
  • The Camera
  • Tilesets
  • Regions
  • Drawing Text & HUDs
  • Changing Scenes
  • Music, Sounds & Channels
  • Backgrounds
  • Customizing Actors
  • Chapter 4 Challenge

5: Game Mechanics

  • Saving
  • Pausing
  • 3rd Party Services
  • Web Requests

6: Advanced Topics

  • Get/Set Attributes
  • Custom Events
  • Blending Modes
  • Lists
  • Custom Blocks
  • Continuous Collisions

7: Testing & Tuning

  • Testing Games
  • Optimizing Performance 1
  • Optimizing Performance 2

8: The Last 10%

  • Flash Publishing
  • Standalone Apps
  • iOS App Store
  • Chrome Store
  • Making Money

M1: Mobile - Intro

  • Getting Started
  • Testing on your Device
  • Flash -> iOS Guide

M2: Mobile - Basics

  • Atlases
  • Drawing Text
  • Retina Display
  • Accelerometer
  • Joystick
  • Universal Games

M3: Mobile - Services

  • iAds
  • Game Center
  • In-App Purchases

M4: Mobile - Publishing

  • Debugging
  • Publishing to the App Store
  • Optimizing Performance
  • Promoting your Game

A: Troubleshooting

  • Showstoppers
  • General FAQ
  • iOS FAQ
  • The 90% Memory Warning
  • Recovering Broken Games
  • Can't Export to SWF
  • Reloading Documents
  • Generating Logs
  • Flash Security Settings
  • How to Report Bugs

B: How-To Guides

  • Importing Assets
  • Scene Designer
  • Code Mode
  • Font Editor
  • Pencyl (Image Editor)
  • Tile Editor (Shapes)
  • Game Cleaner

C: Reference

  • Glossary
  • Block Reference
  • Useful Shortcuts
  • Stencyl API

D: Resources

  • Stencyl TV
  • Abigayl's Guides
  • Giving Critiques
  • Creating Extensions
  • Translating Stencyl
  • Credits

3.0 Drafts (In Progress)

  • What's New in Stencyl 3.0?
  • Setup (Android)
  • Setup (Desktop)
  • Setup (iOS) - Concepts
  • Setup (iOS) - Mac
  • Setup (iOS) - Windows
  • Testing iOS on Windows
  • iOS Troubleshooter

  • Mobile App Scaling
  • Full Screen Mode
  • Simple Physics
  • Backgrounding an App

  • iOS App Store
  • Mac App Store
  • Windows Store
  • Google Play
  • HTML5

  • Android Ads
  • Android Purchases (WIP)
  • 4" Form Factor (iPhone 5)
  • Mobile Input
  • Mobile Features

  • Extending the Engine
  • iOS / Android Extensions
  • Developing the Official Extensions
  • Developing the Engine

  • iAds (Revised)
  • Game Center (Revised)
  • iOS Purchases (Revised)
  • Atlases (Revised)
  • Drawing Text (Revised)
  • Joystick (Revised)
  • Accelerometer (Revised)
  • Sounds (Revised, WIP)
  • Debugging (Revised, WIP)
  • iOS Performance (Revised)
Level: Beginner

Using the Joystick

Contents

  • Introduction
  • Showing the Joystick
  • Changing the Joystick's Appearance
  • Joystick Behavior
  • Dual Joysticks

 

Introduction

Some games involve moving a character around in a wide range of directions. Often, these games require a joystick to provide precise-enough control over that character’s movements.

Creating the logic yourself that would allow joystick input would be cumbersome. Thankfully, we’ve built this functionality into Stencyl, and it just takes a couple of steps to enable it!


How to Enable and Use the Joystick

To enable the joystick and access its values, use the blocks shown below. They’re located under the User Input > Mobile category.

Joystick direction ranges from 0 to 360 degrees, inclusive.

Joystick distance equals how far the user has “stretched” the joystick relative to its center, in pixels.

Example

The following example code, used in the Joystick example game, shows how to use the blocks to implement 360-degree player movement.

Don’t panic about the math - you can find this behavior on StencylForge by searching for “Joystick” or as part of your local Library when importing a behavior (From Your Library > Mobile > Joystick).

You can adjust the “-10” values shown next to the joystick distance block to tune the sensitivity and movement to your liking.


Changing the Joystick's Appearance

You can change the Joystick’s appearance and how it appears on the screen through the Settings > Mobile > Joystick page.

Access the Joystick Configuration Page

Click the Settings button, as shown, to open the dialog:

Settings Button

Next, click Mobile > User Input, as shown in #1 and #2.

Mobile joystick settings.

Changing the Appearance is a matter of providing two graphics - one for the "background" and one for the moveable portion of the josytick.

Tip: Don't want to display the joystick at all? Provide blank graphics.

 

Changing the Behavior

Note: In Stencyl 3.0, joystick behavior is controlled through a block under User Input > Mobile.

You have full control over when and where the joystick appears on the screen. In Stencyl 2.2, this is on the same page where you provided the graphics. In Stencyl 3.0, these are exclusively controlled through blocks under User Input > Mobile.

The Show where Pressed option shows the joystick where the user last touched the screen.

The Fixed option shows the joystick at a fixed position on screen. To set this position, use the following block, located under the User Input > Mobile category.

 

Dual Joysticks

Note: Dual Joysticks are available in Stencyl 3.0 and above.

As the name suggests, dual joysticks let you work with two joysticks rather than one. All of the key joystick operations can now be applied to Joystick 1, Joystick or both of them.

[TODO: Dual joystick motion example]



Last Updated: 2013-04-10 by Jon

7702 have read this article
Disclaimer: The Stencyl Team does not actively monitor comments on articles. If you're seeking help for your game, please ask a question on the forums. Thanks!
6 Comments
Jon
Ben - You could achieve it by inputting blank joystick graphics for both fields.
0 2 months, 1 week ago
benplant
Does anyone know of a way to have the joystick not be visible on the screen? I'd like to allow the movement of the joystick without it actually being visible.
0 4 months, 2 weeks ago
brainmeats
I could really use a second joystick for my game
0 8 months, 1 week ago
dvfe
@ Stevetheipad:
Thank you for your response. I tried to tweak the default joystick to only follow the 4-way movement but I couldn't do it. It seems to be quite complicated to just tell it which direction to follow. There doesn't seem to be a way to do it.

0 10 months, 1 day ago
Stevetheipad
@dvfe: Just program a behavior (or work off the default) that accepts the joystick to be moved in all directions, but detects whether it's going up, down, right or left the most, and only goes in the appropriate direction.
0 10 months, 1 day ago
dvfe
What if I want my actor to walk in a 4-way movement, instead of 360?? How do I configure the joystick?
1 10 months, 3 weeks ago



Commenting Guidelines

Sign In to Comment

Make Games

  • What is Stencyl?
  • Roadmap
  • Pricing

Play

  • Arcade
  • Showcase

Community

  • Forums
  • Chat
  • Translations

Help

  • Stencylpedia
  • Stencyl TV

About Us

  • Blog
  • Contact Us
  • Press
  • Privacy
Follow Stencyl on Twitter



© 2013 Stencyl, LLC.