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 / When to use sync(), swap(), update() or Render()?

Author
Message
HomerS
17
Years of Service
User Offline
Joined: 8th Apr 2007
Location:
Posted: 13th Dec 2014 12:10
Hi all,

I just strarted with agk2 (used dbc in the past).

When i looked at the CloneSprite() example, in the help menu(F1), the cross was made with lines. Between these lines swap, udate and render was used.

I don't understand this, why not using only sync() at the end?

And when do we use a udate() and not a sync() or render() for example?

Toedeledoki
paulrobson
9
Years of Service
User Offline
Joined: 22nd Nov 2014
Location: Norfolk, England
Posted: 13th Dec 2014 12:16
I *think* that Swap just swaps the buffers around without doing sprite updates and so on. Update does this. So sync looks like it just does update then swap.

I think it's good that people submit example code but perhaps someone could politely suggest they comment it more extensively
unlikely
12
Years of Service
User Offline
Joined: 5th Mar 2012
Location: Ohio, USA
Posted: 13th Dec 2014 19:16 Edited at: 13th Dec 2014 19:39
For reference (from the docs):



There are also 2D and 3D specific versions of these commands if you need more control over whether your 2D is rendered in front of or behind any 3D. Or you can do multiple stages of drawing using these commands if you need to do something more complex... There are other creative uses as well, like rendering things to a separate render image...

In the CloneSprite() example, they were a little overzealous with the Update(0) and Render(). They were creating a sprite to use in the example so you don't have to provide your own just to run it. I'm sure the intention was to draw the X to the buffer (using Render()), grab an image to use for the sprite (using GetImage()), and then clone it (using CloneSprite()). All of that wasn't strictly needed, however.

Check out this portion of the GetImage() docs:



Basically, unless you are having trouble getting the effect you want, I would just stick with the good 'ol Sync for the most part.
HomerS
17
Years of Service
User Offline
Joined: 8th Apr 2007
Location:
Posted: 13th Dec 2014 21:24
thank you all for the information.

for me it is more clear now and takes me to the point of experimenting with these codes. lol

greetings.



Toedeledoki
unlikely
12
Years of Service
User Offline
Joined: 5th Mar 2012
Location: Ohio, USA
Posted: 13th Dec 2014 21:51
Quote: "and takes me to the point of experimenting with these codes."


And that, IMO, is the best way to understand!
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 14th Dec 2014 05:07
I use the different commands in my screenshot routine.
To get a screenshot on iOS i get the screen before the last step or i get black.
Try doing some test and you will understand the difference in the commands.

Login to post a reply

Server time is: 2024-05-02 21:22:51
Your offset time is: 2024-05-02 21:22:51