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.

Newcomers AppGameKit Corner / [SOLVED] Issue with Render()

Author
Message
Richard Stevens
4
Years of Service
User Offline
Joined: 14th Jan 2020
Location:
Posted: 16th Aug 2020 17:49 Edited at: 16th Aug 2020 17:55
Me again

I'm having a bit of an issue I was hoping someone could help with.

In my game I was having an issue with sync(). I am using drawsprite() to repeatedly draw the same sprite in the same frame a lot. When sync() was called, some of the sprites were drawn again messing up my depth.

So I changed from using sync() to swap() instead. This is great, as I drawsprite() everything in order, this works fine.

However, now I've lost my text. I've found out that the text is drawn on render() --- the problem being, if I call render() before swap() it gives me my text back, but takes me back to square one with some sprites being drawn again.

Can I call drawsprite() only the text somehow, without doing a full render() ? I only really need the text for debugging but its a bit of a pain turning it on and off.

Thanks.

The author of this post has marked a post as an answer.

Go to answer

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 16th Aug 2020 22:40 Edited at: 17th Aug 2020 06:00
There are a few steps in the sync() process.
Maybe this will help
The description explains the steps
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 17th Aug 2020 02:46 Edited at: 17th Aug 2020 02:47
This post has been marked by the post author as the answer.
Quote: "When sync() was called, some of the sprites were drawn again"

i'm guessing that you were using DrawSprite on those same "re-drawn" Sprites. If so, after you DrawSprite, try setting the actual sprite invisible before Sync() (then back on again. Rinse and Repeat).

Quote: "now I've lost my text"

i'm assuming by "text" you mean Print()-ed "text"? Skip Print() and use the Text Commands, instead, with DrawText() wherever you want it.

Quote: "its a bit of a pain turning it on and off."

how do you mean? Use a Flag? IE, I generally use a Global DEBUG variable (set to either 0 or 1). Then, usage of If DEBUG = 1 then DoSomething() throughout the code

i am making assumptions of what you're looking to do but trying to help with somewhat limited info provided
[My Itch.io Home] | [AGK Resource Directory] | [TGC @ GitHub]
[CODE lang=AGK] Your Code Here [/CODE]
[VIDEO=youtube] VideoID [/VIDEO]
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 17th Aug 2020 15:10 Edited at: 17th Aug 2020 15:22
GetImage() has a nice explanation of the process of Sync() and how to use ClearScreen() to keep things in order...

Quote: "
...When Sync is called AppGameKit updates the positions of all objects with Update, then draws them all to the back buffer with Render, without clearing it, then displays the back buffer to the screen with Swap. It then clears the back buffer and returns to your code, so if you were to call GetImage immediately after Sync you would get a blank image filled with the current clear color. Therefore if you want to grab an image of the current scene fully drawn you must call Render then GetImage then ClearScreen to clear the back buffer so Sync doesn't redraw everything over a fully drawn depth buffer. If you are already using Update, Render, and Swap yourself instead of Sync, then call GetImage between Render and Swap.
"


So, while this may not be much help it still explains a little about things being able to get quirky if one of the steps are omitted, or out of place.


Quote: "
I am using drawsprite() to repeatedly draw the same sprite in the same frame a lot."

I don't use DrawSprite(), as I just set things invisible or move them off screen.

I often cheat when having a lot of images share the same space and set them up in one sprite using an animation and just set/play the frame(s) I want.
(even have a blank frame at the end of the animation to cheat on the invisible sometimes)

I depend mostly on just Sync() and do not go into the separate processes.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Richard Stevens
4
Years of Service
User Offline
Joined: 14th Jan 2020
Location:
Posted: 20th Aug 2020 16:57 Edited at: 20th Aug 2020 17:00
"i'm assuming by "text" you mean Print()-ed "text"? Skip Print() and use the Text Commands, instead, with DrawText() wherever you want it."


Perfect thank you! - that solves my problem nicely. It looks so much prettier too!
Richard Stevens
4
Years of Service
User Offline
Joined: 14th Jan 2020
Location:
Posted: 20th Aug 2020 16:59
"I don't use DrawSprite(), as I just set things invisible or move them off screen."

Ahh, now if I'd have thought of that I probably wouldn't have had to mess with render() at all

Thanks! I'll try that next time.

Login to post a reply

Server time is: 2024-11-21 12:56:07
Your offset time is: 2024-11-21 12:56:07