Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / having a joystick move where player touch

Author
Message
dandrews
1
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 17th Nov 2021 16:54
im trying to get a joystick to only show where and when a player touches but i cant get it to read the angle after. it moves to where the player touches but ive tried different combinations of getpointerreleased(), getpointerpressed() and getpointerstate() with no luck
hendron
5
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 17th Nov 2021 17:46 Edited at: 17th Nov 2021 17:47
I would guess that the reason it's not reading input is because the virtual joysticks don't seem to start listening for pointer movement until the pointer has fired a pressed event while in contact with the joystick. This prevents the joystick from responding to drag events that didn't originate over the joystick. In your code, you're moving the joystick position to the pointer position after the pressed event has already fired while not in contact with the virtual joystick. So to do what you want you'd probably have to code your own virtual joystick.
Game_Code_here
1
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 17th Nov 2021 19:29 Edited at: 17th Nov 2021 19:39
edit neverminded, I read you example wrong.

Steve Ancell
15
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 17th Nov 2021 23:02 Edited at: 17th Nov 2021 23:07
I don't even use the built-in joystick I just do this.


PartTimeCoder
AGK Tool Maker
6
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 17th Nov 2021 23:10 Edited at: 17th Nov 2021 23:12
Quote: "different combinations of getpointerreleased(), getpointerpressed() and getpointerstate()"


Are generic "all-in-one" convenience functions, you are going to need to use "RawTouch" functions for this I think

I encountered this getting my 3D camera code working on mobile GetPointer* was good for nothing more than a simple tap event, anything above and beyond that required RawTouch.

I am sure there was a multitouch example on the forums somewhere where you could use your thumbs for dual stick and the sticks would show where your thumbs touched the screen (within a boundaries) .... but cant find it, anyone have that in their codebase?

Edit: or what ^^ he said, RawTouch is the answer I am sure
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Virtual Nomad
Moderator
15
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Nov 2021 04:10
similar where i'd i tinkered with a virtual trackball awhile back. thanks for reminding me of that game.
dandrews
1
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 18th Nov 2021 17:59
Quote: "I don't even use the built-in joystick I just do this."


hmmm i think ill play around with creating my own as well thank you. i have two joy sticks as of now ,one for movement and one for aiming. one will only show on the right side of the screen and the other on the left
Steve Ancell
15
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 19th Nov 2021 12:49
Quote: "
hmmm i think ill play around with creating my own as well thank you. i have two joy sticks as of now ,one for movement and one for aiming. one will only show on the right side of the screen and the other on the left
"


Have fun with that, you'll be glad you did.
Game_Code_here
1
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 21st Nov 2021 07:04
Even if this code will work your telling it not to work because you change the flags before the action.

pressed2 can not equal 1 till after you move the virtual joystick. Because you said do this if this flag is this.

so here is how it should look.



dandrews
1
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 22nd Nov 2021 18:41 Edited at: 22nd Nov 2021 18:45
thank you game code ill pay more attention in the future to this. now i have a question of changing my joystick angles with the drag angles. do i simple replace the getvirtualjoystickangle(joystick2) with getdragangle() like this

or do i need to make the "angle" of the dragangle global and use that? i was able to get the player animation to change correctly depending on the dragangle just by replacing them like so but the bullets do not move or travel in the direction of the touch like they would with the joystick
Game_Code_here
1
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 23rd Nov 2021 09:42 Edited at: 23rd Nov 2021 09:47
Quote: "or do i need to make the "angle" of the dragangle global and use that? "


That depends, is your main angle function out of the main program ?

Your jumping function to function so yes, set everything in a global so every function is updated to use that info.

So you touch the screen and a bullet follows that direction and its angle is set.


Quote: "gun.bullets[i].angley= Gun.Bullets [ i ].speed *GetRawTouchCurrentY(1)"


This does not check your fingers angle if you are needing this for a phone.

You need a lot of different checks for the bullet angle on the path it is following.

so if spritemovey=1 then setspriteangle so on and so forth.

Or just set your sprite angle to turn around as it follows a path .

I would add a helper sprite for the bullet to face at all times.

Keep that sprite in front of the bullet at all times.

EDIT

I searched and found this example, this will rotate a sprite at your fingers pos.




dandrews
1
Years of Service
User Offline
Joined: 26th Jun 2020
Location:
Posted: 25th Nov 2021 04:06 Edited at: 25th Nov 2021 19:15
Quote: "I searched and found this example, this will rotate a sprite at your fingers pos."

awsome i was able to get a turret to rotate with the mouse getpointer pos.


so with the bullets i think i have to set a y point to travel towards instead of the raw touch since it constantly changing. so when the bullet becomes active somehow save that y pos for it to travel towards so in the code below set angley as whatever the rawtouch was at that point the bullet started moving


Edit: its the math im struggling with im unsure of what equation to do to find the right way to have the bullet travel towards where i want it. i can get it to move but never in exactly the right angle i need

Login to post a reply

Server time is: 2021-11-27 05:42:22
Your offset time is: 2021-11-27 05:42:22