Edited by BenRK, 08 April 2012 - 04:06 AM.
[How To] [Studio] A True Analog Stick
#21
Posted 08 April 2012 - 04:06 AM
#22
Posted 08 April 2012 - 04:37 AM
#23
Posted 12 April 2012 - 03:05 PM
Ah, I forgot about that.
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!
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.
#24
Posted 12 April 2012 - 04:47 PM
This is awsome! Thanks for such a great example I REALLY apreciate it!
#25
Posted 12 April 2012 - 10:12 PM
Ah, I forgot about that.
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!
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.
Edited by cotycrg, 28 April 2012 - 12:05 AM.
#26
Posted 14 April 2012 - 03:43 AM
#27
Posted 23 April 2012 - 03:00 AM
#28
Posted 27 May 2012 - 01:42 PM
#29
Posted 27 May 2012 - 10:19 PM
#30
Posted 28 May 2012 - 01:55 PM
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.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)?
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.
#31
Posted 28 May 2012 - 06:04 PM
#32
Posted 29 May 2012 - 04:07 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..
Basically this makes the analog a lot smaller and with a smaller boundary.
#33
Posted 29 May 2012 - 06:22 PM
This works until i click on the analog stick... When i click on it, the same problem occurs.. the view goes odd.
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.
#34
Posted 29 May 2012 - 09:59 PM
..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.This works until i click on the analog stick... When i click on it, the same problem occurs.. the view goes odd.
#35
Posted 07 June 2012 - 12:03 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)){
#36
Posted 22 June 2012 - 09:09 AM
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.
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)?
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!
#37
Posted 10 July 2012 - 11:52 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.
#38
Posted 12 July 2012 - 04:01 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.
#39
Posted 30 July 2012 - 01:09 PM
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:11 PM.
#40
Posted 03 August 2012 - 12:59 AM
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 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











