Newbie Asks: How do you destroy Actor once Out of screen

Non-platform specific questions.

Newbie Asks: How do you destroy Actor once Out of screen

Postby ggesterGamePro99 » Wed Apr 25, 2012 8:48 pm

I read the OPTIMIIZATION techniques thread and they said
you should destroy the actors once they're not visible in the screen.

So for example, my planeed game is a mario style side scrolling game.

So my question is
once i pass the screen and the enemy or whatever is not visible any more
AND Also if the player destroys (by punching or whatever) an enemy, i should destroy them right?

How do i do that? Do i do it in the script editor?
And how?
Just a wild guess is:
in the script editor for the enemy, when player has punching animation and he is coliding with me( the enemy) and I'm(the enemy) not blocking, add to the GOTHIT Counter and if it equals 5 then I die--> DestroyActor( "event Actor");

OR If I'm(the enemy) still alive, but not visible in screen anymore--> DestroyActor("event actor");

Is this how to do it?
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: Newbie Asks: How do you destroy Actor once Out of screen

Postby ggesterGamePro99 » Wed Apr 25, 2012 8:52 pm

But i was thinking..That worked in mario because in mario.(at least in mario 1 ), once you move forward and things are left behind. you can't really return to the start area of the game. so if characters are destroyed...that's fine.

But what if it's a game, where characters that stayed behind remain there and you can go back and meet them again.
So in this case if you Destoryed them then...that can't happen.

Mmmmm.....
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: Newbie Asks: How do you destroy Actor once Out of screen

Postby ggesterGamePro99 » Wed Apr 25, 2012 10:20 pm

Anyways, what code would i check to see if the Character is out of the visible screen area.

But usually we want the ones behind the Player to disapear( after the screen has moved forwards).
but we don't want the enemies ahead to be destroyed right?
ggesterGamePro99
 
Posts: 44
Joined: Mon Apr 16, 2012 1:53 am
Score: 0 Give a positive score

Re: Newbie Asks: How do you destroy Actor once Out of screen

Postby skydereign » Wed Apr 25, 2012 10:33 pm

You can destroy things that leave the screen by adding an out of vision event. If you want them only to be destroyed by them moving to the left of the screen, you can use an if statement (x<view.x) for instance.

Another tip is to not use collision events for your enemy actor. And do you know about "Collide Actor"? It is like using "Event Actor" but it specifies the actor that the event actor is colliding with (only works in collision events). So if you want to destroy the other actor (the enemy) you can use DestroyActor("Collide Actor"). There is also collide, which you can use to check the colliding actor's variables.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest