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 / Weird movement of sprites with functions

Author
Message
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 31st Jan 2013 22:27 Edited at: 3rd Feb 2013 20:23
______________MATTER RESOLVED - FILES REMOVED_________________
Hey once again fellow AppGameKit developers, I am in need of some help. So to add some animation to a main menu of my current project, I decided to make the screen like swipe in a direction moving all the sprites in direction XYZ and then revealing the chosen option.

Problem is that for some reason if I press the "settings" button before I have pressed the "how to play" button, it glitches, but if I restart and press the "how to play" button first, then the settings button works fine!?

I am doing the movement with four different functions which look like this:


And I call them like so:


I have attached my project, PLEASE NOTE THAT TO REVERT TO THE MAIN MENU, YOU SIMPLY CLICK THE SCREEN.

Thanks
//Anton[b][/b]
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Feb 2013 15:39
What version of AppGameKit?

For starters "setsyncrate ( 600 , 0 )" is not practical or good. Getting a reliable sync rate of 30 across all platforms is doable. One of 60 is not always and 600 is not right at all.

Trying to set that kind of sync rate really affects the sensitivity of the app. It overloads it trying to process things.

Even if it could perform the way you want. The human eye really doesn't process things at 600 frames a second.

I would recommend doing one check for getpointerpressed (not four) and within that section, store the pointer x/y in variables (so you only do two function calls) and then compare against each sprite for a hit. And use something like:


This will reduce overhead calls and make sure that the code only processes one button, but checks for all each time there is a pointer press.

By calling getpointerpressed so many times, you actually miss the one you want.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 1st Feb 2013 15:52 Edited at: 1st Feb 2013 16:03
Ah I see, thats some really good Advice I'll start fixing that straigh t away. Just a few things, me settings the syncrate to 600 is just so that my "swipe" effect is smooth, otherwise I have to do steps of 1 which make it look really quite bad. I will have a play around! Also I'm making this app just for PC atm.

Version 1.7 AGK

EDIT: so I have done what you said, except the syncrate part, I'll fix that later and figure out a way to make it look good, however I still have the same problem of it spazing out on specific buttons if you press them first.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Feb 2013 17:04 Edited at: 1st Feb 2013 17:04
1.7? The current 'official' release is v1076.

How close are your buttons? And what size are they?

Edit: And do they overlap at all?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 2nd Feb 2013 17:30
My buttons are about 1.5 % apart from eachother and they vary in size from around 50% , 30%...

My version is 107 ... sorry
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 2nd Feb 2013 17:50
Are you using the percentage system then? (Not setting virtual resolution.)

That explains using small numbers and why moving by 1 makes it look like it jumps.

As for the version, did you download v1076 from your TGC 'My Products' page or are you using an older version?

Try adding something that reports the values of pointerx and pointery when you click. The Message command can be used to pop up text. This might help you identify whether the clicks (touches) are happening where you think they are.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 2nd Feb 2013 20:19
Ok, I will update AppGameKit, and then Ill test out your theory, however the problem is that when the button which is first in the code is pressed first it works... Its when the button, which's code is underneath is pressed, it does not work, I tried moving the code around and found this.
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 3rd Feb 2013 14:01
Ok, so after testing that, and seeing the X and Y values of my clicks, I conclude that nothing out of the ordinary is going on.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Feb 2013 17:48
Did you change to the if x elseif x elseif?

Also try this variant:


This might or might not fix the problem. It will certainly speed up the performance because you do only 4 function calls every time you test instead of up to 16 from your original code.

And you don't have the "setspriteposition ( Si1 ..." command in MenuSwipeRight and MenuSwipeDown. This results in the sprite indicated by the passed value not actually displaying. It starts from wherever it was and moves off the screen. As opposed to starting just off the edge and moving in as it does in MenuSwipeLeft and MenuSwipeUp.

I suspect that some of your problem might be in making sure that the sprite that you want to display after everything clears is not being initialised to the correct position to 'appear'. You should make sure that the position for the sprite that is supposed to be left on the display is initialised in all of the swipe functions.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 3rd Feb 2013 20:22
Ok, finally, I've fixed this peice of crap.

What I had to do was add position updates at the beggining of each function, and add a few position sets before the loop. I also changed the "finding out which sprite was clicked" code to one that I knew worked.

Thank you soooo much Ancient Lady, you've helped me with every single problem I have posted on here! I am ever in your debt!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th Feb 2013 15:26
While I don't have the patience to be a proper teacher, I can't not help people.

You are welcome. Good luck with your project.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-05-06 12:57:00
Your offset time is: 2024-05-06 12:57:00