Virtual Joystick - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: Virtual Joystick (/thread-9965.html)
Virtual Joystick - xctive - Apr 5, 2012 01:48 PM
Does anyone know of a good way to implement a virtual joystick without using Cocos2D and SneakyJoystick
RE: Virtual Joystick - skyhawk - Apr 5, 2012 02:08 PM
use sneaky joystick in cocos2d?
I mean it's pretty straight forward. you attach it to your scene, and then you just read the vector from it.
Not sure what else you need to know or want to know. If you're asking a design question, that's something entirely different.
RE: Virtual Joystick - xctive - Apr 5, 2012 03:37 PM
I cannot include the cocos2d framework I need an individual class and I am not quite sure how to get it done ive been looking at sneakys but everything relates to the cocos framework.
RE: Virtual Joystick - skyhawk - Apr 5, 2012 03:57 PM
I know justinfic just recently implemented a virtual joystick for his game kung fu killforce. maybe if I can somehow summon him here
RE: Virtual Joystick - JustinFic - Apr 5, 2012 05:47 PM
(Apr 5, 2012 03:57 PM)skyhawk Wrote: I know justinfic just recently implemented a virtual joystick for his game kung fu killforce. maybe if I can somehow summon him here
I do indeed have my own virtual joystick. I do not use Cocos2D-- it's all hand rolled stuff. What specifically do you want to know?
RE: Virtual Joystick - xctive - Apr 5, 2012 06:29 PM
I am just looking for an easier way to implement a virtual joystick... If you wouldn't mind I would like to take a look at your joystick class and maybe understand the process a little more.
RE: Virtual Joystick - JustinFic - Apr 6, 2012 10:46 AM
The functionality is spread across a bunch of classes in the engine-- if you're looking for an all-in-one solution you'd be better off with the cocos joystick. I've been told my engine is pretty lovecraftian.
Design-wise, at its simplest you just want to have a center point on screen (around which your joystick is drawn), then within a certain radius of that, track the user's touch position and get a vector going from the center to the touch pos. Normalize that vector, and you'll get an input range of -1 to 1 in the x and y directions.
RE: Virtual Joystick - Frank C. - Apr 6, 2012 07:36 PM
Like others I've rolled my own (closed source, sorry). These aren't difficult to get going, but there are a lot of usability issues you need to consider. There's a really good article about virtual sticks here: http://www.gamasutra.com/view/feature/134693/a_guide_to_ios_twin_stick_shooter_.php
My personal preference are dynamic sticks that appear centred on the first touch, then follow your thumb if you go beyond the radius. These feel better than static sticks since a swipe greater than the radius in the opposite direction *always* changes direction, no matter how far your thumb may have wandered from the original start point. The game doesn't even have to draw these or call them "sticks". It becomes a more natural "touch and swipe to move" interface. This setup might not work for every game, but the less you try to emulate physical controls the better IMHO.
RE: Virtual Joystick - JustinFic - Apr 7, 2012 12:33 PM
Nice, that article is excellent, although I think it makes an assumption that the first touch should always be zeroed-- as if you were touching your thumb to an analog stick-- and that the player always wants to tap-and-swipe to initiate movement.
Personally, my joysticks stay visible centered around one point, but the touch region is quite a bit bigger than the joystick on-screen and the radius for tracking the finger once you touch it is huge. And I do like tapping on the edge of a joystick for quick instant movement in that direction without having to swipe.
That said, I'm biased in that direction because my games tend to be VERY heavily based on twitch.
Quote:the less you try to emulate physical controls the better IMHO
This, a thousand times! While I do like evoking the feeling of old arcade controls (mine look and sound similar) I think mechanically you have to create something from the ground up for touchscreens.
RE: Virtual Joystick - ThemsAllTook - Apr 8, 2012 05:57 PM
Slides from a GDC talk about this topic. Some interesting stuff in here. http://www.stfj.net/ControlsYouCanFeel-ZachGage-GDC2012.pdf