Jump to content


Photo
- - - - -

[How To] [Studio] A True Analog Stick


  • Please log in to reply
82 replies to this topic

#1 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 31 March 2012 - 04:30 AM

Well I noticed a few people were having issues with Analog sticks on a touchscreen. I decided to tackle the issue myself. This is pretty close to the code I use for Scribble Space (it's a little simpler in my game, since I only need to move on the x axis around the room).

Here's the example, first off: http://crossedshadow...ick_Example.zip (you need to extract it to get the .gmz)

Example Screenshot: Posted Image

I hope this helps out some people. It'd be nice to play some games on my Android that have proper analog controls. Well, now there's no excuse for you guys! :thumbsup:

PS. This can be implemented to have up to 5 analog sticks, if you really needed. Because I included multi-touch functions for everything. The thing where it detects if you're still holding your finger down and you're outside the analog dead-zone even works with multiple analog sticks, as well. Just be careful with placement and check the create event to make sure you're putting the sticks where you really want them! This can even be configured a bit to where the analog stick moves with the finger, if moving to far out, to adjust to the player's play-style. I know the UnReal engine tried something with that, awhile back, so it might be fun to play with. Get creative!

Be sure to post any errors or any mistakes in my code or example in this thread.. Or any way to be more efficient!

Edit: Alright, I removed the code from this post. You couldn't copy/paste it anyways because of the way the forum formatted things, it just messed stuff up. I have the link posted above still for you to view. Another reason for me to remove it was because the code is a bit more complicated now in ordering, because I made the analog stick smooth for moving on the x and y axis around the room. I hope you enjoy!
I made it so that the math for the analog stick is now in the draw event, right next to where it actually draws the stick. I did this because it makes it much smoother when moving around the room.

Edited by cotycrg, 11 October 2012 - 04:34 PM.

  • 9

#2 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 31 March 2012 - 05:15 AM

Your example at the top is 404'd by the way.

Akkk..my bad. Apparently my ftp won't let people download .gmz files..changed it to a .zip. Oh well. Thanks for the heads up!
  • 0

#3 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 31 March 2012 - 12:01 PM

A single analog stick can be got by mapping all other controls to virtual keys, and doing calculations to calculate vector from center of analog to mouse position when it's down.
For two analog sticks you will need to use YoYo_MouseX(n) (seemingly?).
I did such control scheme in my HTML5 game tu.blast() (though that wasn't done in GM).

Essentially, yes. I'm already using YoYo_Mouse in this setup, though. So to make another analog, you'd simply have to make a new set of variables and copy/paste the analog code using the new variables.
  • 0

#4 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 31 March 2012 - 12:32 PM

Very nice demo. Well written and commented and the demo showed off some nice interactivity. Posted Image

After playing with it for a while I got some lag, and then I realized the bullets never destroyed themselves. I just made them destroy after leaving the room and everything's a-Okay. Posted Image

+1

Aha. Yeah, I didn't think that far into it, as I was making it really only for the analog. ..I actually didn't even plan the bullets or button..but then I got inspired for a SPACEGAEM. So I figured, why not, for including it in the demo. haha
  • 0

#5 SLarouche

SLarouche

    GMC Member

  • GMC Member
  • 95 posts
  • Version:GM:Studio

Posted 31 March 2012 - 03:44 PM

Well I noticed a few people were having issues with Analog sticks on a touchscreen. I decided to tackle the issue myself, and even use my method in a game as a control option in my game later. Anyways..here's and example and how to do it.


Very, very nice example. Works like a charm on my galaxy nexus!

Thank you very much.

Smon
  • 0

#6 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 03 April 2012 - 06:08 PM

Well I noticed a few people were having issues with Analog sticks on a touchscreen. I decided to tackle the issue myself, and even use my method in a game as a control option in my game later. Anyways..here's and example and how to do it.


Very, very nice example. Works like a charm on my galaxy nexus!

Thank you very much.

Smon

I love to help! I'm glad everyone is liking this. I might update it a bit to make it more clear, if anyone wants.
  • 0

#7 EyeCandy

EyeCandy

    GMC Member

  • GMC Member
  • 9 posts
  • Version:GM:Studio

Posted 04 April 2012 - 01:03 AM

At the risk of making myself look like a complete idiot...how do I open .gmz files with GameMaker Studio? It doesn't seem to recognize the file type. It has been a pretty good while since I last messed with GameMaker, but with Studio in beta and approaching a release date I want to dive in. I currently make apps using another program, but the ability to make games with such ease is just unbeatable on GM. Anyway, some guidance would be great! :)
  • 0

#8 EyeCandy

EyeCandy

    GMC Member

  • GMC Member
  • 9 posts
  • Version:GM:Studio

Posted 04 April 2012 - 04:55 PM

Drag the gmz file into the launcher window after you start studio.


Thanks!


I tested the example on my Xoom tablet and I gotta say it runs extremely smooth. This will come in handy to many who need to use analog sticks in there games. Very nice :)
  • 0

#9 jn2002dk

jn2002dk

    GMC Member

  • New Member
  • 58 posts

Posted 04 April 2012 - 05:17 PM

Awesome

This will certainly save me a lot of time

Thank you! :smile:
  • 0

#10 Smarty

Smarty

    GMC Member

  • GMC Elder
  • 7522 posts
  • Version:GM:Studio

Posted 05 April 2012 - 11:27 AM

//checks for holding, even if out of 'bounds' //this is so that if the user starts holding the analog stick and moves their finger out of the bounds, it doesn't ignore the touch, it keeps following until THAT finger is lifted! (works on C++ runner too!)

Some time ago I was working on a comparable interface, but rather the 4-way and 8-way classical joysticks, forcing the visible stick to go into the cardinal and ordinal directions based on the joystick type required. A downside however is that fingers aren't very accurate, and tend to slide further than the joystick can reach. I too solved this by simply keeping the joystick pushed until the finger was lifted (and only following if it came into the detection areas).

But what I really would love to do be able to give off a very short vibration once the stick touches the perimeter, as if it is touched. It would be a short signal to inform the player that moving their finger further away will only increase the distance from the base (degrading his accuracy and reaction speed) as well as give the joystick a more solid feel through subtle force feedback. I understood that there are reservations within YYG to put functions in GM:Studio to buzz the phone, and judging from the documentation it's still not there. I know it's a feature that can become a nuisance rather than a joy, but I'd still like them to let us make that judgement call ourselves (after all we can still make obnoxious games if we wanted to).
  • 1

#11 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 05 April 2012 - 12:11 PM

//checks for holding, even if out of 'bounds' //this is so that if the user starts holding the analog stick and moves their finger out of the bounds, it doesn't ignore the touch, it keeps following until THAT finger is lifted! (works on C++ runner too!)

Some time ago I was working on a comparable interface, but rather the 4-way and 8-way classical joysticks, forcing the visible stick to go into the cardinal and ordinal directions based on the joystick type required. A downside however is that fingers aren't very accurate, and tend to slide further than the joystick can reach. I too solved this by simply keeping the joystick pushed until the finger was lifted (and only following if it came into the detection areas).

But what I really would love to do be able to give off a very short vibration once the stick touches the perimeter, as if it is touched. It would be a short signal to inform the player that moving their finger further away will only increase the distance from the base (degrading his accuracy and reaction speed) as well as give the joystick a more solid feel through subtle force feedback. I understood that there are reservations within YYG to put functions in GM:Studio to buzz the phone, and judging from the documentation it's still not there. I know it's a feature that can become a nuisance rather than a joy, but I'd still like them to let us make that judgement call ourselves (after all we can still make obnoxious games if we wanted to).

I would also love this. Have you ever played with N64oid? They do a similar thing, and it is very helpful. The trick is to barely vibrate on the tick of the tap, and to barely vibrate when reaching the limit. It's also a nice effect for buttons themselves, on the touchscreen.

Though, it's always good to have an in-game option for the user to turn it up/down/off. Everyone's opinions on that matter seem varied.
  • 0

#12 Smarty

Smarty

    GMC Member

  • GMC Elder
  • 7522 posts
  • Version:GM:Studio

Posted 05 April 2012 - 12:18 PM

I would also love this. Have you ever played with N64oid? They do a similar thing, and it is very helpful. The trick is to barely vibrate on the tick of the tap, and to barely vibrate when reaching the limit. It's also a nice effect for buttons themselves, on the touchscreen.

No I haven't, but it is good to know that it is already a proven concept.

Though, it's always good to have an in-game option for the user to turn it up/down/off. Everyone's opinions on that matter seem varied.

Obviously. Speaking of which, when having controls such as the one you developed you also might want to give the players some accuracy and sensitivity parameters to play with.
  • 0

#13 adam2386

adam2386

    GMC Member

  • New Member
  • 2 posts
  • Version:Unknown

Posted 05 April 2012 - 06:06 PM

Quick question, Lets say I was to make the background bigger so the ship could navigate throughout a map. I have been messing around and when I do that, the analog moves off screen and doesn't stay in the corner to be able to follow the ship.

BTW, way nice example!
  • 0

#14 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 05 April 2012 - 11:27 PM

Quick question, Lets say I was to make the background bigger so the ship could navigate throughout a map. I have been messing around and when I do that, the analog moves off screen and doesn't stay in the corner to be able to follow the ship.

BTW, way nice example!

Ah, I forgot about that.

Simply add view_xview[0 or 1 or 2..] to everything that has to do with yoyo_mousex and view_yview with everything that has to do with yoyo_mousey. Also add view_xview to everything drawn on the x coordinate and so on and so on.

It'd make it follow the screen. If you don't understand, I could update the example.
  • 0

#15 BenRK

BenRK

    Now in high-definition!

  • GMC Member
  • 855 posts
  • Version:GM:Studio

Posted 07 April 2012 - 05:02 AM

This is the issue I'm having with the help file. Those YoYo functions used in this example are not listed in the help file, at least not everywhere I've looked. SOME are, like the virtual keys and stuff, but those YoYo mouse functions for multi touch? I wish I had known about those, hmmmm?

Maybe I'm just looking in the wrong spot, but if ALL the YoYo functions were listed in the YoYo function section, then there wouldn't be an issue, would there?
  • 0

#16 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 08 April 2012 - 02:01 AM

This is the issue I'm having with the help file. Those YoYo functions used in this example are not listed in the help file, at least not everywhere I've looked. SOME are, like the virtual keys and stuff, but those YoYo mouse functions for multi touch? I wish I had known about those, hmmmm?

Maybe I'm just looking in the wrong spot, but if ALL the YoYo functions were listed in the YoYo function section, then there wouldn't be an issue, would there?

The help file hasn't been updated properly yet. It should be around the time GM:S is released. For now, the new functions only show up in that autocorrect thing in the code editor boxes.
  • 0

#17 BenRK

BenRK

    Now in high-definition!

  • GMC Member
  • 855 posts
  • Version:GM:Studio

Posted 08 April 2012 - 04:20 AM

I know, and it's becoming a real problem. How can I test these things when they wont even tell me they are there? How they work?

Edited by BenRK, 08 April 2012 - 04:20 AM.

  • 0

#18 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 08 April 2012 - 04:51 AM

That's what the GMC is for. It's a beta. This isn't intended for normal use yet.
  • 0

#19 adam2386

adam2386

    GMC Member

  • New Member
  • 2 posts
  • Version:Unknown

Posted 12 April 2012 - 03:19 PM

Quick question, Lets say I was to make the background bigger so the ship could navigate throughout a map. I have been messing around and when I do that, the analog moves off screen and doesn't stay in the corner to be able to follow the ship.

BTW, way nice example!

Ah, I forgot about that.

Simply add view_xview[0 or 1 or 2..] to everything that has to do with yoyo_mousex and view_yview with everything that has to do with yoyo_mousey. Also add view_xview to everything drawn on the x coordinate and so on and so on.

It'd make it follow the screen. If you don't understand, I could update the example.


Thanks for the quick reply, I should be able to manage without the example, but if it doesn't take too much time to put the example up, that may be good for others who are looking to do the same.
  • 0

#20 Samuel Venable

Samuel Venable

    GMC Member

  • Banned Users
  • 632 posts
  • Version:GM:Studio

Posted 12 April 2012 - 05:01 PM

H*** yeahh!! I've been waiting forever to find out how to do that ever since ZooEscape by sakis25 games got ported to mobile!
This is awsome! Thanks for such a great example I REALLY apreciate it! :)
Spoiler

#21 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 12 April 2012 - 10:26 PM

Quick question, Lets say I was to make the background bigger so the ship could navigate throughout a map. I have been messing around and when I do that, the analog moves off screen and doesn't stay in the corner to be able to follow the ship.

BTW, way nice example!

Ah, I forgot about that.

Simply add view_xview[0 or 1 or 2..] to everything that has to do with yoyo_mousex and view_yview with everything that has to do with yoyo_mousey. Also add view_xview to everything drawn on the x coordinate and so on and so on.

It'd make it follow the screen. If you don't understand, I could update the example.


Thanks for the quick reply, I should be able to manage without the example, but if it doesn't take too much time to put the example up, that may be good for others who are looking to do the same.

Well in my version of the file, it now supports moving across the room, using the analog stick and virtual button as an overlay. I just need to rip out that code into a new project and post it. I'll do that later tonight, hopefully. (done)

Edited by cotycrg, 28 April 2012 - 12:19 AM.

  • 0

#22 wagdog

wagdog

    GMC Member

  • GMC Member
  • 282 posts
  • Version:GM:Studio

Posted 14 April 2012 - 03:57 AM

Thank you for this example, it was very useful.
  • 0

Three Liter Games

Kitty Flyer (FREE!) - Flappy Bird like game:

iOS: iTunes App Store

Android: Google Play!

Lunar Commander:

iOS: iTunes App Store

Android: Google Play

Linux: Lunar Commander Linux - (free - direct download)

HTML5: http://www.johnnywag.com/lchtml5/ (play free in your browser!)

Lunar Commander Lite (FREE!):

iOS: iTunes App Store

Android: Google Play

 


#23 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 23 April 2012 - 03:14 AM

Finally got around to updating it. Sorry that took so long, I've been working on a million different things. But I put it all aside for this (we need decent analog sticks in people's games!! I hate WASD analogs.. Takes the whole point out of having an analog, and SO many games do that!)
  • 0

#24 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 27 May 2012 - 01:56 PM

Updated to the latest GM:Studio .gmz. Not sure if there is any difference in the file..but either way. Here.
  • 0

#25 Fireball16

Fireball16

    Indie Developer

  • GMC Member
  • 1015 posts
  • Version:GM:Studio

Posted 27 May 2012 - 10:33 PM

Hi quick question before I try this, does it just go I'm the standard 4 ways (up, down, left, right) or 8 ways (north, north east, east, etc)?
  • 0

twitter128x12832.pngbrowser128x12832.pngandroid128x12832.pngskype128x12832.png


#26 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 28 May 2012 - 02:09 PM

Hi quick question before I try this, does it just go I'm the standard 4 ways (up, down, left, right) or 8 ways (north, north east, east, etc)?

This does all 360 degrees. It also controls speed. If you make simple if/then checks, then you can make your own 4/8 way things.

eg: if(analog_direction>45 and analog_direction<115){analog_up=1;}else{analog_up=0;}

or something like that. The analog variables that my math returns aren't the standard 0 through 360, simply because of the way cosine/sine work. But just make a little debug text on the top that shows analog_direction and you'll figure it out.
  • 0

#27 Fireball16

Fireball16

    Indie Developer

  • GMC Member
  • 1015 posts
  • Version:GM:Studio

Posted 28 May 2012 - 06:18 PM

Ok, problem. The view is 480px by 320px. When i add the obj_analog to the room, the view for some reason stays really far up in the room (to a bit i havent even made) and all the text i have draw is squished on top of each other... How to fix this?
  • 0

twitter128x12832.pngbrowser128x12832.pngandroid128x12832.pngskype128x12832.png


#28 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 29 May 2012 - 04:21 AM

Ok, problem. The view is 480px by 320px. When i add the obj_analog to the room, the view for some reason stays really far up in the room (to a bit i havent even made) and all the text i have draw is squished on top of each other... How to fix this?


That can be one of two things (as I can't access Studio right now, I'm going to try and figure it out in my head. I wish the licensing issue would be fixed already!)

My first idea is that your port is not the same as your view or something. If they are not the same, they need to be at least scaled proportionally correctly.

If they are, then try this code in the create event instead..
Spoiler


Basically this makes the analog a lot smaller and with a smaller boundary.
  • 0

#29 Fireball16

Fireball16

    Indie Developer

  • GMC Member
  • 1015 posts
  • Version:GM:Studio

Posted 29 May 2012 - 06:36 PM

Ok, problem. The view is 480px by 320px. When i add the obj_analog to the room, the view for some reason stays really far up in the room (to a bit i havent even made) and all the text i have draw is squished on top of each other... How to fix this?


That can be one of two things (as I can't access Studio right now, I'm going to try and figure it out in my head. I wish the licensing issue would be fixed already!)

My first idea is that your port is not the same as your view or something. If they are not the same, they need to be at least scaled proportionally correctly.

If they are, then try this code in the create event instead..
Spoiler


Basically this makes the analog a lot smaller and with a smaller boundary.

This works until i click on the analog stick... When i click on it, the same problem occurs.. the view goes odd.
  • 0

twitter128x12832.pngbrowser128x12832.pngandroid128x12832.pngskype128x12832.png


#30 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 29 May 2012 - 10:13 PM

This works until i click on the analog stick... When i click on it, the same problem occurs.. the view goes odd.

..you must be doing something seriously wrong in your code, haha. If you want, you can PM me an example of what you're trying to do and I can try debugging it for you.
  • 0

#31 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 07 June 2012 - 12:17 AM

!

Turns out there was a little bug in my example. When you would try to move your ship to far right (when using a move-able view), you would end up pressing right on the analog stick if you hit "shoot" on a mobile device. I fixed it in the OP, though.

Specifically, it's this line..
 if (YoYo_MouseCheckButton(ddevice,mb_left) and ((YoYo_MouseX(ddevice)>((analog_x)/4)+view_xview and YoYo_MouseY(ddevice)>((analog_y)/4)+view_yview and  YoYo_MouseX(ddevice)<((analog_x+analog_width)*1.5)+view_xview and YoYo_MouseY(ddevice)<((analog_y+analog_height)*1.5))+view_yview or device_used=ddevice)){

Change it to this...
 if (YoYo_MouseCheckButton(ddevice,mb_left) and ((YoYo_MouseX(ddevice)>((analog_x)/4)+view_xview and YoYo_MouseY(ddevice)>((analog_y)/4)+view_yview and  YoYo_MouseX(ddevice)<((analog_x+analog_width)*1.5)+view_xview and YoYo_MouseY(ddevice)<((analog_y+analog_height)*1.5)+view_yview) or device_used=ddevice)){

  • 0

#32 ObsidianNovels

ObsidianNovels

    GMC Member

  • GMC Member
  • 717 posts
  • Version:GM:HTML5

Posted 22 June 2012 - 09:23 AM

Hi quick question before I try this, does it just go I'm the standard 4 ways (up, down, left, right) or 8 ways (north, north east, east, etc)?

This does all 360 degrees. It also controls speed. If you make simple if/then checks, then you can make your own 4/8 way things.

eg: if(analog_direction>45 and analog_direction<115){analog_up=1;}else{analog_up=0;}

or something like that. The analog variables that my math returns aren't the standard 0 through 360, simply because of the way cosine/sine work. But just make a little debug text on the top that shows analog_direction and you'll figure it out.


Simply add this little code into the step-event and refer to it to get the normal 0-360 degrees:

currentAngle = analog_direction_ship mod 360;
if (analog_direction_ship < 0) currentAngle += 360;

Love your example, cotycrg. It's very good!
  • 0

#33 japes00

japes00

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM:Studio

Posted 10 July 2012 - 12:06 PM

!

Turns out there was a little bug in my example. When you would try to move your ship to far right (when using a move-able view), you would end up pressing right on the analog stick if you hit "shoot" on a mobile device. I fixed it in the OP, though.

Specifically, it's this line..

 if (YoYo_MouseCheckButton(ddevice,mb_left) and ((YoYo_MouseX(ddevice)>((analog_x)/4)+view_xview and YoYo_MouseY(ddevice)>((analog_y)/4)+view_yview and  YoYo_MouseX(ddevice)<((analog_x+analog_width)*1.5)+view_xview and YoYo_MouseY(ddevice)<((analog_y+analog_height)*1.5))+view_yview or device_used=ddevice)){

Change it to this...
 if (YoYo_MouseCheckButton(ddevice,mb_left) and ((YoYo_MouseX(ddevice)>((analog_x)/4)+view_xview and YoYo_MouseY(ddevice)>((analog_y)/4)+view_yview and  YoYo_MouseX(ddevice)<((analog_x+analog_width)*1.5)+view_xview and YoYo_MouseY(ddevice)<((analog_y+analog_height)*1.5)+view_yview) or device_used=ddevice)){


Great example... but this bug also happens if you place the stick on the right hand side,
also if you press on the top of a screen ( same side as the stick) it also happens.
  • 0

#34 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 12 July 2012 - 04:15 AM

!

Turns out there was a little bug in my example. When you would try to move your ship to far right (when using a move-able view), you would end up pressing right on the analog stick if you hit "shoot" on a mobile device. I fixed it in the OP, though.

Specifically, it's this line..

 if (YoYo_MouseCheckButton(ddevice,mb_left) and ((YoYo_MouseX(ddevice)>((analog_x)/4)+view_xview and YoYo_MouseY(ddevice)>((analog_y)/4)+view_yview and  YoYo_MouseX(ddevice)<((analog_x+analog_width)*1.5)+view_xview and YoYo_MouseY(ddevice)<((analog_y+analog_height)*1.5))+view_yview or device_used=ddevice)){

Change it to this...
 if (YoYo_MouseCheckButton(ddevice,mb_left) and ((YoYo_MouseX(ddevice)>((analog_x)/4)+view_xview and YoYo_MouseY(ddevice)>((analog_y)/4)+view_yview and  YoYo_MouseX(ddevice)<((analog_x+analog_width)*1.5)+view_xview and YoYo_MouseY(ddevice)<((analog_y+analog_height)*1.5)+view_yview) or device_used=ddevice)){


Great example... but this bug also happens if you place the stick on the right hand side,
also if you press on the top of a screen ( same side as the stick) it also happens.


It's not a bug, it's deadzone configuration. Just replace what you quoted and it "fixes" it. Compare the two to see how I did the deadzone. I'll update the example soon to have a "deadzone" variable so its easier to mess with.
  • 0

#35 Mariux

Mariux

    GMC Member

  • GMC Member
  • 4 posts
  • Version:GM:Studio

Posted 30 July 2012 - 01:23 PM

Hi,

first of all thanks for this great example!

Let's say I want to add to my object a constant speed of +2 in x axis in order to follow a the view (that's moving to the right with a speed of -2), where I have to edit the x movement?

Thanks!

Edited by Mariux, 30 July 2012 - 01:25 PM.

  • 0

#36 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 03 August 2012 - 01:13 AM

..do you mean similar to how Scribble Space works? (Basically you're always going right).

In which case; it might be easier to make everything else go left. Or, just do something different than I'm doing with speeds. Just do hspeed=2 or something?
  • 0

#37 blackhawkrobbo

blackhawkrobbo

    GMC Member

  • GMC Member
  • 1121 posts
  • Version:GM:Studio

Posted 03 September 2012 - 05:11 PM

Damn, i just made another one xD Didn't see this one.

Here's mine, it has much less code, but i'm not sure wich one is best.

http://gmc.yoyogames...howtopic=552875
  • 0

#38 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 04 September 2012 - 02:39 PM

Damn, i just made another one xD Didn't see this one.

Here's mine, it has much less code, but i'm not sure wich one is best.

http://gmc.yoyogames...howtopic=552875

Not bad. But yours has a couple drawbacks mine doesn't. (Yours doesn't have multitouch, and it requires an option for the analog stick. Mine supports multi touch and even multiple analog sticks; and also yours is stuck as a square analog type. Which makes it a little jumpy in nature)

Edited by cotycrg, 04 September 2012 - 02:40 PM.

  • 0

#39 blackhawkrobbo

blackhawkrobbo

    GMC Member

  • GMC Member
  • 1121 posts
  • Version:GM:Studio

Posted 04 September 2012 - 02:43 PM

Damn, i just made another one xD Didn't see this one.

Here's mine, it has much less code, but i'm not sure wich one is best.

http://gmc.yoyogames...howtopic=552875

Not bad. But yours has a couple drawbacks mine doesn't. (Yours doesn't have multitouch, and it requires an option for the analog stick. Mine supports multi touch and even multiple analog sticks; and also yours is stuck as a square analog type. Which makes it a little jumpy in nature)


Yeah, you're right. I've made this in 10 minutes as an example for another member here.

Im going to check yours out tonight, wonder how you fixed the multitouch.. The round analog instead of the square involves some math.. In which i suck real hard.
  • 0

#40 Derme

Derme

    Time for a break.

  • GMC Member
  • 489 posts
  • Version:GM:Studio

Posted 05 September 2012 - 07:38 AM

Nice tutorial, didn't end you using the joystick, as I already made my own.

But I didn't even consider using a virtual key for the shoot button, seeing your example solved all my problems! (Well a couple GM related ones) :P

Thanks.
  • 0
TwitterBanner_zpsf5eaf370.pngSignBanner_zps6e538aa2.pngjust21_promo_graphic_zps785b873f.png

#41 adam3

adam3

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:Studio

Posted 05 September 2012 - 04:31 PM

Hi, I am new to GMS. Currently I'm trying to create a game for Android. I have been searching on how to create an analog stick. I found your sample and tried to run it in GMS. But it says 'Unknown function or script: YoYo_MouseCheckButton' and 'Unknown function or script: YoYo_MouseX'. Do you know why this happened?
  • 0

#42 adam3

adam3

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:Studio

Posted 05 September 2012 - 04:33 PM

Well I noticed a few people were having issues with Analog sticks on a touchscreen. I decided to tackle the issue myself, and even use my method in a game as a control option in my game later. Anyways..here's and example and how to do it.

Here's the example, first off: http://crossedshadow...ick_Example.zip (you need to extract it to get the .gmz)

Example Snapshot: Posted Image


The example has a few more things in it, and is commented too. I'm posting a bit more dummed down version in the thread, as to help with any confusion of how it works.

First, make a create event. In it, have this:

Spoiler


Here's some code that is in the Step event:
Spoiler


This stuff is in the draw event:
Spoiler



I hope this helps out some people. It'd be nice to play some games on my android that have proper analog controls. Well, now there's no excuse for you lot! ;)

PS. This can be implemented to have up to 5 analog sticks, in all reality. Because I, of course, included multitouch functionality. The thing where it detects if you're still holding your finger down and you're outside the analog deadzone even works with multiple analog sticks, as well. This can even be configured a bit to where the analog stick moves with the finger, if moving to far out, to adjust to the player's playstyle. I know the UnReal engine tried something with that, awhile back.

Be sure to post any errors or any mistakes in my code or example in this thread.. Or any way to be more effecient!

Edit: Well it looks like the code has some extra line spaces where they should be..it's the forum I suppose. I cannot change that. It's fine in the example, if the code posted here gives you problems.



Hi, I am new to GMS. Currently I'm trying to create a game for Android. I have been searching on how to create an analog stick. I found your sample and tried to run it in GMS. But it says 'Unknown function or script: YoYo_MouseCheckButton' and 'Unknown function or script: YoYo_MouseX'. Do you know why this happened?
  • 0

#43 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 05 September 2012 - 11:13 PM

Hi, I am new to GMS. Currently I'm trying to create a game for Android. I have been searching on how to create an analog stick. I found your sample and tried to run it in GMS. But it says 'Unknown function or script: YoYo_MouseCheckButton' and 'Unknown function or script: YoYo_MouseX'. Do you know why this happened?

Ah! I have no idea what the new functions are!! Let me check the help file.. (this is what the function names were in the beta)

Edit: Change YoYo_MouseX to device_mouse_x.
Edit edit: I changed them all for you, in the OP. Didn't update the .GMZ though. If I missed anything on the OP lemme know.

Edited by cotycrg, 05 September 2012 - 11:40 PM.

  • 0

#44 adam3

adam3

    GMC Member

  • New Member
  • 5 posts
  • Version:GM:Studio

Posted 06 September 2012 - 09:42 AM

Ah! I have no idea what the new functions are!! Let me check the help file.. (this is what the function names were in the beta)

Edit: Change YoYo_MouseX to device_mouse_x.
Edit edit: I changed them all for you, in the OP. Didn't update the .GMZ though. If I missed anything on the OP lemme know.



I have changed all the necessary code like you suggested, but now it says "Unknown function: device_mouse_check_button" and "Unknown function: device_mouse_x".
Please guide me. Thank you.
  • 0

#45 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 06 September 2012 - 12:19 PM

Ah! I have no idea what the new functions are!! Let me check the help file.. (this is what the function names were in the beta)

Edit: Change YoYo_MouseX to device_mouse_x.
Edit edit: I changed them all for you, in the OP. Didn't update the .GMZ though. If I missed anything on the OP lemme know.



I have changed all the necessary code like you suggested, but now it says "Unknown function: device_mouse_check_button" and "Unknown function: device_mouse_x".
Please guide me. Thank you.

HMMMMM. I'll go ahead and try and fix it really quick, sorry about that. I haven't had to change mine and the error doesn't show up for me because it detects its from the beta and will use the old functions on my machine for some reason.

Edit: I updated both the code in the OP and the .GMZ file. So now it should work fine.

Edited by cotycrg, 06 September 2012 - 02:55 PM.

  • 0

#46 bdgscotland

bdgscotland

    GMC Member

  • GMC Member
  • 4 posts
  • Version:GM:Studio

Posted 18 September 2012 - 08:38 AM

Hi there. I've been trying to get this working properly with my view that scrolls both horizontally as well as vertically.
Strangely, the co-ords reported (if using draw_text) for device_mouse_x and device_mouse_y seem to be incorrect. Anyway, not for this post.
I finally got it working but it seems there is a problem with your logic. You multiply the start position + the width (or height) by 1.5. Really, you only want to be multiplying the width or the height to give the desired effect of having a 'loose' area for people to fat finger. Below is what I changed it to.
I also had to update the create event to base the position of analog_y on the view_hport instead of your room_height. This keeps everything relational to the view rather than the room.

Otherwise, FANTASTIC example. I would never have managed to figure out the math on this myself. Thank you.
Duncan

if (device_mouse_check_button(ddevice,mb_left)  and (device_mouse_x(ddevice)>(analog_x/4)+view_xview) and (device_mouse_y(ddevice)>(analog_y/4)+view_yview)    and (device_mouse_x(ddevice)<analog_x+(analog_width*1.5)+view_xview)   and  (device_mouse_y(ddevice)<analog_y+(analog_height*1.5)+view_yview) or device_used=ddevice){

  • 1

#47 ChikinSloat

ChikinSloat

    GMC Member

  • New Member
  • 115 posts

Posted 23 September 2012 - 02:32 AM

I'm trying this in HTML5. I was under the impression it supported multi-touch with the device numbers...but nope. When I try this example, I can manoeuvre fine, but when hit "fire", the other finger still controls the first mouse and stops my movement. Any suggestions?

From what I can find, only device "0" is recognized...no others.

Edit: Because GM:S blows and doesn't want to fix this, I just had to rig my own multi-touch twin-stick shooter system. Mostly works like a charm!

Edited by ChikinSloat, 23 September 2012 - 04:37 AM.

  • 0

#48 blackhawkrobbo

blackhawkrobbo

    GMC Member

  • GMC Member
  • 1121 posts
  • Version:GM:Studio

Posted 25 September 2012 - 09:32 PM

I'm trying this in HTML5. I was under the impression it supported multi-touch with the device numbers...but nope. When I try this example, I can manoeuvre fine, but when hit "fire", the other finger still controls the first mouse and stops my movement. Any suggestions?

From what I can find, only device "0" is recognized...no others.

Edit: Because GM:S blows and doesn't want to fix this, I just had to rig my own multi-touch twin-stick shooter system. Mostly works like a charm!


Then share it with us :)
  • 0

#49 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 874 posts
  • Version:GM:Studio

Posted 25 September 2012 - 10:04 PM

I'm trying this in HTML5. I was under the impression it supported multi-touch with the device numbers...but nope. When I try this example, I can manoeuvre fine, but when hit "fire", the other finger still controls the first mouse and stops my movement. Any suggestions?

From what I can find, only device "0" is recognized...no others.

Edit: Because GM:S blows and doesn't want to fix this, I just had to rig my own multi-touch twin-stick shooter system. Mostly works like a charm!

As far as I know, HTML5 supports multi-touch. Most browsers don't.

My example would work fine for multi touch, if you were to, say, use two objects, both having the multi touch code (the easy way). Or you could even make it all one object by copy/pasting my code and making two sets of variables (gets messy, but more efficient). It checks all (5) of the touches, 0-4.
  • 0

#50 JStaples2006

JStaples2006

    GMC Member

  • New Member
  • 17 posts
  • Version:Unknown

Posted 10 October 2012 - 02:32 AM

Ah, I forgot about that.

Simply add view_xview[0 or 1 or 2..] to everything that has to do with yoyo_mousex and view_yview with everything that has to do with yoyo_mousey. Also add view_xview to everything drawn on the x coordinate and so on and so on.

It'd make it follow the screen. If you don't understand, I could update the example.


hey cotycrg! i dont quite understand this part. im have the same problem with the analog stick sliding off the screen at points, and i added in the code, but maybe i have missed something? could you send me a PM or post a code snippet as an example of what you mean?
  • 0