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 / [Answered]AGK T1 Basic: Trying to ClearScreen to black, but not working.

Author
Message
David Gervais
Retired Moderator
13
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 15th Jan 2015 15:48
Ok, imagine my game screen all filled with sprites, a nice GUI, score table etc.. all I want to do is clear the screen to black, but the ClearScreen() does not seem to work.



does not work, all my sprites are still visible.. adding.. Render() or Swap() also seems to have no effect.

From what I read about ClearScreen() is that is seems to only affect the back buffer, but it also seems that 'Screen' affected is tha same part of the screen that is 'Under' all of my sprites. so it is having no visual effect..

A work around would be to create an image 1024x768 (all black) and than creating a sprite with that and placing that on screen with a depth of 1.. forcing it to be on top..

Come on guys I'm gonna smack someone on the head.. don't call a command 'ClearScreen()' if all it does is clear a backbuffer.

another alternative is for me to hide all the sprites showing to return the screen back to the black background. Seems like a lot of work just to get a clear black screen.

Any insights would be appreciated. Thanks.

JLMoondog
Moderator
10
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 15th Jan 2015 16:38 Edited at: 15th Jan 2015 16:40
Hey David! I was playing around with the ClearScreen() and it does do it's job. What I think is happening in your program is you're still updating your sprites at the end of your program by using sync() or another form. If you want to use ClearScreen() you can do something like this:



Basically this will sync everything onscreen until you click your mouse. Than it will clear/swap the backbuffer and not continue to update the sprites.

I do not like this method. I think clearscreen() wasn't meant for literally clearing the screen to start fresh, but to clear it for one loop cycle.

So other ways would be to do a screen sprite like you mentioned, or hide the sprites, or move them off screen. Do you plan to reuse the sprites you wish to clear?

I personally in my last few apps have either faded the sprites to 0 alpha or moved them off-screen to be used later.

<a href="http://www.slidedb.com/games/kayak-escape" title="View Kayak Escape! on Slide DB" target="_blank"><img src="http://button.slidedb.com/popularity/medium/games/34310.png" alt="Kayak Escape!" /></a>
David Gervais
Retired Moderator
13
Years of Service
User Offline
Joined: 28th Sep 2005
Location: Montreal, Canada
Posted: 15th Jan 2015 17:00 Edited at: 15th Jan 2015 17:14
Hi there JLMoondog,

Thanks for the quick reply.. Yeah after more investigation I think the sprite update thing was the problem.

But I needed this only at the end game where I say goodbye thanks for playing, so my ultimate solution was to create a 64x48 black sprite and SetSpriteSize(BlackBKG, 1024,768) and fade the alphs from 0 to 255, this had the nice effect of making the screen look like it fade out. (fade to black) if you know what I mean.

Problem solved. Sorry for spanking AppGameKit for a misleading ClearScreen() command. This work-around works great.

Cheers!

P.S. I'll be posting my game soon, I finally got around to finishing my Tumble Match game. (just a few more odds and ends to finish the game over (play Again/Quit) type thing.)

BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Jan 2015 18:01
I use a very similar method to your fade to black.

Think of visible sprites as a collection of images you always draw to the screen on Sync(), regardless of whatever else is going on.

Quidquid latine dictum sit, altum sonatur
Conjured Entertainment
AGK Developer
13
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 19th Jan 2015 17:25
I fade to black from green setting the screen color, and like how it works.
Yeah, making the sprites invisible as you go is the way to go.
I even fade the sounds master volume too for a nice effect for ending credits before a game closes.
Try 6 Marbles to see example. (no background music yet, but the sound is fading in the code and works as tested in another game)


Using AppGameKit V1 Tier 1

Login to post a reply

Server time is: 2019-08-21 05:59:49
Your offset time is: 2019-08-21 05:59:49