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 Classic Chat / Virtual Joystick

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 4th Jan 2014 16:19 Edited at: 4th Jan 2014 16:20
Hi.

I want when VirtualJoystickX > 0 Change Sprite Animation to wallk. I wrote this code but don't Change Animation.



Please Guide Me.
Thanks
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 4th Jan 2014 16:42
Try adding if GetSpritePlaying(Player) = 0 as a condition before PlaySprite...
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th Jan 2014 18:04
Also, check the State variable before you do the changes. If it is already equal to 2, don't do anything. Your code has the effect of always resetting your sprite each frame as long as the joystick is being used. You want it to start the animation the first time it sees the joystick value change and then not do anything until it goes back to zero.



Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 4th Jan 2014 18:05 Edited at: 5th Jan 2014 15:27
Thanks Ancient Lady. I try your code but it run very very fast I change the values in PlaySprite Function but don't change any thing. I don't know where is the problem.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 8th Jan 2014 19:39 Edited at: 8th Jan 2014 20:11
Hi.

I fix the Problem and this is my code. also I attached Player Sprites.



But I have some questions:

1- why when release Joystick the Player Glide on the floor?

2- I want use Original Sprite size, and think there is problem in SetSpriteOffset, SetSpriteSize and SetSpritePositionByOffset.
I don't good know why should use them. please explanation.

3- how can disable Miles down and Miles up? because when joystick is Miles down or Miles up the speed decrease. I want Joystick work only in 4 direction.
Thanks

Attachments

Login to view attachments
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Jan 2014 10:35 Edited at: 10th Jan 2014 10:36
I fix the Player Glide and improve my code. But I need more information about two other issues. can any one help me?

Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 12th Jan 2014 13:17
The following lines

Don't actually do anything. It is setting the size of the sprite based on what it already is.

If you load the images first, you can use one these to create the sprite. Then the sprite will take on the size of the image and the offset will also be set up for you.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 16th Jan 2014 08:45
My Sprite show very large.
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 16th Jan 2014 22:42 Edited at: 16th Jan 2014 22:42
Quote: "3- how can disable Miles down and Miles up? because when joystick is Miles down or Miles up the speed decrease. I want Joystick work only in 4 direction."


I downloaded your sprites and had a look at your code (from the 10th of jan) and if I understand the issue correctly then I think what you need to do is convert the joystickx into a simple move left, move right or don't move parameter. Below is a modified version of your code.



What I've done is to save the getVirtualJoystickX(1) value to a variable and then used this to calculate another variable "direction_x" that has values -1 (move left) 0 (don't move) and 1 (move right) then applied this throughout the code. You can use the same I hope this is what you wanted or if not I hope it gives some ideas.

I've not looked at the sprite size issue but, as Marl said, you need to load the images first and then create the sprites. What you can then do is change the size of the sprites using the setSpriteSize or setSpriteScale commands.

Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 17th Jan 2014 04:35 Edited at: 17th Jan 2014 04:43
Quote: "My Sprite show very large."


The image "p1_stand" is 66 x 92 pixels.

This suggests that you are using the percentage coordinate system. This has the range 0 to 100 each way, so the image will be almost full height of the screen and about two thirds of the width.

The tip for using the image to create the sprite works with virtual resolution, for the percentage system the sprite size will need adjusting ( multiply by 100/ physical resolution );


Which is closer to how you had it, so may be what you were working towards.

@29 games
The other way to convert analogue to digital is;

It has the same affect, but doesn't us a floating point division so should be faster.

Login to post a reply

Server time is: 2024-05-02 18:12:32
Your offset time is: 2024-05-02 18:12:32