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 / using Sync() in a loop

Author
Message
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 2nd Jan 2014 04:52
I have been told not to use Sync() in a loop becuase it is taxing on the CPU. But if I do not use it then the following code will not work:



Take the Sync() out and it will not continue.

I am using beta of V2 and this is happening on a PC. I have not tried Android yet as I am still developing. However, the same thing happens in V1 build 108.

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 2nd Jan 2014 05:51
Who told you to not use sync()?

It's just about the most important command out of the lot. It updates the physics, gets all input (Mouse/Touch/Keys etc), and updates the physics

mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 2nd Jan 2014 06:39
They didn't say "not use at all", but not as the above code snippet uses it. I was told to use it only when I need to update the screen.

Don't remember the screen name.

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Jan 2014 11:27
If sync does indeed update the input calls, then yes you'll need it for that code snippet. However, if you're looking for a way to pause your game until the pointer has been released, there are better methods.

easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 2nd Jan 2014 21:48
Like this:



Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 2nd Jan 2014 22:01
insanity! There are so few things in AppGameKit that work without sync (timer does and HTTP commands do). You need no more than one sync per loop, sometimes you might want to do a timed sync where it only happens so many times per second in a fast loop, but there's not much reason for that.
You may want to use alternatives to sync which are slightly faster.
For example if you are not using 3D then you can replace sync with

Update2D(0) : Render2DFront() : Swap()

Other than that, use sync liberally, but not more than once in a loop as it will cause issues.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 2nd Jan 2014 23:15
easter bunny, I think your snippet should compare to 1 in order to do what mindsclay was showing in his.

Naphier, there are times when you want to make the application not do anything until a pointer is pressed (or released or whatever). Unfortunately, it isn't clear which of the three sub-commands that make up the Sync() command handle user and device inputs. Otherwise, it would be good to use just that one.

Maybe we need a command (that works in both Tiers) to check user/device inputs (touches and tilts).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 3rd Jan 2014 02:02
Quote: "Maybe we need a command (that works in both Tiers) to check user/device inputs (touches and tilts)."

It may already exist for T2 - agk::UpdateInput() is listed in the Wrapper.h. Shouldn't be too much work to introduce it into T1.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Jan 2014 05:04 Edited at: 3rd Jan 2014 05:05
Oh! I never looked at the Wrapper.h file.

I might have to try a test to see if agk::UpdateInput() works (when I can find the time while trying to prepare for my move to Alaska in 9 days).

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 3rd Jan 2014 06:17
It would be great to have a command that updates just the input. HTTP commands seem to run on their own without sync (although I'm scared to leave them that way), but it's often the case that I don't need to draw anything new to the screen so something a bit more static would save a lot of battery juice.

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 3rd Jan 2014 08:16
Quote: "Oh! I never looked at the Wrapper.h file."

There are some nice surprises in there.

Login to post a reply

Server time is: 2024-11-24 23:50:43
Your offset time is: 2024-11-24 23:50:43