Virtual Joysticks Extension [3.1]

Abliblablobla

  • *
  • Posts: 524
Virtual Joysticks Extension


This is a completely new extension for Stencyl 3.x that lets you implement virtual joysticks in your games without a single line of code!

**EDIT by robinschaafsma**
I have update the extension for Openfl (deleted all nme), this extension is working properly.
I have make a example game, to let you see how to set up the Joystick properly.
Also a new extras folder is available for download at the bottom of this post.

<a href="http://www.byrobin.nl/stencyl/joystick/Virtual%20Joystick%20Extension.swf" target="_blank" class="new_win">http://www.byrobin.nl/stencyl/joystick/Virtual%20Joystick%20Extension.swf</a>

Download the example game from StencylForge or at the bottom of this post.

A WIKI page is available here: https://github.com/byrobingames/Virtual-Joystick/wiki
I try to update this page when i have the chance, input is welkom.

**End EDIT by robinschaafsma**

Key Features
 - Cross-platform extension: use the same blocks for different platforms and screen sizes!
 - Choose between static and relative joysticks!
 - Add as many joystick as you want to the screen!
 - Easily customize each joystick in a different way!

Blocks
 - [Improved] Add new static joystick
 - [Improved] Add new relative joystick
 - Remove joystick
 - Get distance/direction of joystick
 - Set/Get joystick position
 - Set/Get inner/outer radius of joystick
 - Always hide joystick when touch/mouse is released
 - Set default joystick direction
 - [NEW!] Set/Get touch region for relative joystick
 - [NEW!] Set joystick image at runtime
 - [NEW!] Set pressed/released joystick transparency
 - [NEW!] Joystick is pressed

To Do
- Set joystick image
 - 2 ways joystick (see example game by robinschaafsma)
 - 4 ways joystick (see example game by robinschaafsma)
- Set/Get touch region position
- Set/Get touch region width/height
- Set default non-pressed image transparency
- Set default pressed image transparency
- Set image transparency
- Joystick is pressed/released
 - ...

You can read more detailed explanations for each block in the documentation attached below and I strongly suggest you to do so!

PLEASE read the documentation I wrote for this extension and do NOT skip the installation chapter! This extension requires an "extras" folder with your joystick images inside. Instead of creating a new "extras" folder you can download, unzip and use the "extras" folder I have attached below.

Help me test this extension!
Creating a true cross-platform extension isn't an easy task when you have to imagine every possible scenario and you have so many variables (screen sizes, aspect ratios, mobile vs desktop, operating systems ...), so help me test this extension!

Share your opinion!
Do you have an idea for a useful block? Feel free to post your opinion and help me improve this extension!

Support me!
This is a completely free extension and it will always be free!
If you feel like you want to thank me with a cup of tea click on the button below to donate. I want to remind you that this is a completely free extension, so you can download and use it for commercial purposes without any donation!


(NOTE: Payments are processed through PayPal. You can use your PayPal account or your credit card to make a donation.)

Changelog
- August 31th 2015: [Fix] Getter blocks not visible.
-  August 24th 2015: NME to OPENFL; [Fix] Default direction. (by robinschaafsma)
 - August 1st 2014: [Fix] Default direction block doesn't work properly.
 - July 14th 2014: Major update [2.0].
 - February 20th 2014: Initial Release [1.0].

« Last Edit: January 08, 2019, 08:40:18 am by robinschaafsma »
.: BuruBuru :.

altobi

  • Posts: 86
Well done! Stencyl needs a better Joystick extension

DoctorXero

  • Posts: 15
EDIT TO PREVENT FUTURE CONFUSION: Resolved this by doing a clean install of the newest nightly build of Stencyl 3.  I'm guessing the problem occurred because I initially installed 3 on top of 2.

It doesn't appear in my extensions list after installation.  Thoughts?

[LOG] Action: Settings
[LOG] [C:\Program Files (x86)\Stencyl\ext-tools\7zip\win\7za.exe, x, C:\Users\Me\Downloads\myjoystick.zip, -oC:\Program Files (x86)\Stencyl\plaf\haxe\extensions, -y, -mmt]
[LOG] 7-Zip (A) 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
[LOG] Processing archive: C:\Users\Me\Downloads\myjoystick.zip
[LOG] Extracting  myjoystick
[LOG] Extracting  myjoystick\.DS_Store
[LOG] Extracting  __MACOSX
[LOG] Extracting  __MACOSX\myjoystick
[LOG] Extracting  __MACOSX\myjoystick\._.DS_Store
[LOG] Extracting  myjoystick\blocks.xml
[LOG] Extracting  __MACOSX\myjoystick\._blocks.xml
[LOG] Extracting  myjoystick\icon.png
[LOG] Extracting  __MACOSX\myjoystick\._icon.png
[LOG] Extracting  myjoystick\include.nmml
[LOG] Extracting  __MACOSX\myjoystick\._include.nmml
[LOG] Extracting  myjoystick\info.txt
[LOG] Extracting  __MACOSX\myjoystick\._info.txt
[LOG] Extracting  myjoystick\MyJoystick.hx
[LOG] Extracting  __MACOSX\myjoystick\._MyJoystick.hx
[LOG] Extracting  __MACOSX\._myjoystick
[LOG] 0
[LOG] Everything is Ok
[ERR] Could not delete file: plaf\haxe\extensions\__MACOSX
[LOG] Loading engine extensions...
[LOG] Folders: 3
[LOG] Files: 13
[LOG] Size:       29269
[LOG] Compressed: 10287
[LOG] Parsing engine extensions...
[LOG] gestures is not an engine extension. Skip.
[LOG] label is an engine extension. Adding.
[LOG] test is an engine extension. Adding.
[LOG] test-flash is an engine extension. Adding.
[LOG] test-native is an engine extension. Adding.
[LOG] tileapi is an engine extension. Adding.
[LOG] Device OS: 5.0
[LOG] Simulator OS: 5.0




« Last Edit: February 20, 2014, 09:29:51 pm by DoctorXero »

Jon

  • *
  • Posts: 17524
It looks like the __MACOSX part that's messing it up. (Abi - Use keka to package up ZIP's on a Mac. The native zipper wraps everything in a __MACOSX which confuses people on Windows but is invisible on a Mac.)

Take the folder *inside* that and place it in the extensions folder.

DoctorXero

  • Posts: 15
I tried placing that folder in the extensions folder in both appdata and program files.  No luck.

EDIT:  Nevermind.  I uninstalled and reinstalled the latest build and it works.

« Last Edit: February 20, 2014, 09:24:45 pm by DoctorXero »

Abliblablobla

  • *
  • Posts: 524
I have just updated myjoystick.zip and extras.zip (compressed using Keka).
.: BuruBuru :.

thinkster

  • Posts: 149
Awesome. I'll give this a go this weekend and let you know how I get on.

I have been hoping something like this would be developed!

Abliblablobla

  • *
  • Posts: 524
Awesome. I'll give this a go this weekend and let you know how I get on.

I have been hoping something like this would be developed!

Did you have the chance to test this extension?
.: BuruBuru :.

mdotedot

  • Posts: 1654
Hello Abliblablobla,

Thank you for your efforts.

First I had put the extras it in the games folder from Stencyl and not my own game. Maybe an extra line of documentation for that?

If you could simulate left,right,up,down press&release in your extension it would help. Also, a way to set the sensitivity would be neat.

Currently I have used it in this mechanism:


Maybe I did something wrong or should have used the relative-joystick?!

Tested: Flash, Native Mac, Android: Galaxy Tab Note 2014 Ed and iOS: iPhone 5s

Best regards from
M.E.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Abliblablobla

  • *
  • Posts: 524
You are welcome mdotedot!

If I understand correctly you are suggesting some blocks for a 4-ways only joystick movement. I think it is a good idea, so I'll add them to the todo list. I will also add a block to detect if a particular joystick is being pressed. I have a couple of ideas about how to implement them but now I want to wait until more people test this extension and confirm that everything is working as expected before adding new features.

For your behaviors: when a joystick is pointing to the right side, "direction" is always between 315 and 360 or between 0 and 45, when it is pointing to the upper side "direction" is between 45 and 135, to the left side it is between 135 and 225, to the lower side it is between 225 and 315.

.: BuruBuru :.

deivkk

  • Posts: 5
I'm very interested in this extension. Where could I get it from?

Abliblablobla

  • *
  • Posts: 524
Hi deivkk!
If you want to try this extension go to the bottom of the first post. There are three download links: the first one is the documentation for this extension, the second one is a folder with some images you need for the joysticks, and the third one is the extension itself. You can read the documentation to understand how to install and use this extension.
.: BuruBuru :.

GuyCockcroft

  • Posts: 193
Hi Ali. This is great stuff - I'm using it at the moment. One thing I'd like to do is to limit the movement of a given joystick to a particular axis. You mentioned doing a 4-way joystick earlier, but I'd love to be able to implement 2 joysticks, one working in the x and one in the y (like an RC car controller).

Thanks again for the extension!

Abliblablobla

  • *
  • Posts: 524
Hi Ali. This is great stuff - I'm using it at the moment. One thing I'd like to do is to limit the movement of a given joystick to a particular axis. You mentioned doing a 4-way joystick earlier, but I'd love to be able to implement 2 joysticks, one working in the x and one in the y (like an RC car controller).

Thanks again for the extension!

Thanks for the feedback!
I will add 2-ways joysticks to the todo list.
.: BuruBuru :.

thinkster

  • Posts: 149
Hey, finally got round to testing this.

I can't install the extension on my mac.

When I go to install extensions I can't select the my joystick folder? It seems not to recognise it as zip folder??

Any ideas?