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 / Best way to start a new level?

Author
Message
2D Analyst
AGK Developer
19
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 19th Oct 2012 21:03
I'm working on a game, where it involve many levels. I don't know how to clear all the sprites and images on screen to blank? I know I need to delete sprites, but what else do I have to consider to clear everything out and start a new level?

kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 19th Oct 2012 21:46 Edited at: 19th Oct 2012 21:46
That is kinda your choice. Deleting all sprites and creating them once again (for bigger RPG maps for example) is costy and can take a really long time.
So, you might want to consider keeping your sprites, but out of player's sight, and adjust their position and image dynamically.

As for the rest, it's up to what game are you doing. It's like, up to your design.

Also, you don't need to set sprite's position somewhere out of the screen if you are going to delete it. Simply delete and it will go off.

Follow me on twitter! @MotionStruct
Motion Struct blog
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 19th Oct 2012 22:03
As Kamac says, it depends somewhat on what your levels look like.

Are they top down? If the screen is full of a grid of sprites, then you could possibly change the image on each sprite instead of deleting/recreating them.

Or is a side-scroller? In that case, making new sprites could be done pretty quickly.

Platformer? Even quicker.

Care to share some details?

2D Analyst
AGK Developer
19
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 20th Oct 2012 00:01
I think I got the idea of positioning the sprite or make it invisible, but how would I clear the background?

Below is the code I use to load the background. Am I better off making the background into a sprite? The image size is 480x800.


Kobaltic
12
Years of Service
User Offline
Joined: 24th Jan 2012
Location: PA, USA
Posted: 20th Oct 2012 00:02
If you use the placement editor you can just unload the level and load a new one.
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 20th Oct 2012 12:30
I've always used the 'move off screen' method, but recently I've been experimenting with the 'DeleteSprite' method and to be honest, I think I prefer it...

To answer your background question though, if you are going with the 'move off screen' method then you would do exactly that with the background too i.e.

2D Analyst
AGK Developer
19
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 20th Oct 2012 17:59
From a performance standpoint,do you think it's better to use the move off screen method or delete sprite for 50 sprites?

Also, since tier 1 is basic language, does this mean there's no need for me to manage the memory? So, when the user exit my app, I don't need to delete all the images, sprites, etc, to free up resource?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Oct 2012 01:13
I have no delay issues deleting sprites in between levels, 50 sprites are created and deleted in under a second. Users also need a break of intensity between levels, so they will not notice the delay.

I always have an Init() and DeInit() function in my games, and write them at the same time.

7RS
11
Years of Service
User Offline
Joined: 10th May 2012
Location:
Posted: 24th Oct 2012 11:18
In our games we use a dynamic load and delete of sprites to use unlimited size maps and we use the delete and of course we use clone. This work pretty well also for large amount of sprites.

Login to post a reply

Server time is: 2024-04-28 00:18:34
Your offset time is: 2024-04-28 00:18:34