Page 1 of 3

Activation Regions

PostPosted: Wed Aug 17, 2011 2:11 pm
by ESL
Hello

Can someone help me with the activation regions?

Suppose I want to create my game all in one .ged file.

One activation region has the start and help buttons

Another one has one level, another one has the next level and so on.

How do I show only one region at a time and then transition to the next region?

I hope you can understand what I am writing.
:)

Re: Activation Regions

PostPosted: Wed Aug 17, 2011 8:45 pm
by skydereign
What I usually do is create some definitions or an array in global code. Don't know if you know arrays, so I'll just explain the definition way.
Global Code
Code: Select all
#define menu_x -300
#define menu_y -240

#define level1_x 1000
#define level1_y -240

// and so on


That way when you want to jump into another activation region, you do this.
Code: Select all
view.x=level1_x;
view.y=level1_y;


Now a property of activation regions is that only regions intersecting with the view are loaded. So besides moving the view into the levels, you don't need to do anything else. Of course depending on how you set up your levels, you might have some trouble. For instance you either need a clone of the player in every level, or you need to move/create one.

Re: Activation Regions

PostPosted: Thu Aug 18, 2011 2:49 am
by ESL
Well, that is something to wrap my head around. It gives me a basic understanding. I will toy with it until I get something working.

Thanks!

Re: Activation Regions

PostPosted: Thu Aug 18, 2011 3:22 am
by ESL
Sorry for my plebian mind. The computer coding still baffles me.

This is not a game, just an example.

In the first region, there is an astronaut.
In the second region, a planet.
In the third region, an explosion.
In the fourth region, a space ship.

When I play in game mode, it shows all four on the screen.

How do I show the first alone, then the second alone, and then the third and fourth?

Re: Activation Regions

PostPosted: Thu Aug 18, 2011 5:07 am
by skydereign
Any and all activation regions intersecting with the view are loaded. So, if the actor is positioned in the view, then naturally it will be loaded. Each region would need to be far enough away so the view can't collide with more than one region at a time. If you want to have some actors show on the screen while having others not appear (even though they are within the view) then you need to do something else, such as disable the other actors' visibility state.

Re: Activation Regions

PostPosted: Thu Aug 18, 2011 5:41 am
by ESL
So what I am getting from this is that I need to change the location of the view actor in order to view another region

How do I do that?

Re: Activation Regions

PostPosted: Thu Aug 18, 2011 5:49 am
by skydereign
Yeah, so it is like I said above. Each level must be far enough apart, and to move the view to the different regions, you set the view's x and y values. So if clicking an actor is supposed to jump you to level 1, the code would look like this.
button -> Mouse Button Down (left) -> Script Editor
Code: Select all
view.x=1000;
view.y=-240;

Re: Activation Regions

PostPosted: Thu Aug 18, 2011 6:05 am
by ESL
cool, that did the trick. Now I just need to know how to position the coordinates correctly.

Re: Activation Regions

PostPosted: Thu Aug 18, 2011 6:10 am
by skydereign
Well you can use the trick I mentioned above. The only things to note are that the view's position is the top left pixel, so find what pixel the top left of the view should be based at, and write it down. You could also use actors to hold the position if you wanted to.

Re: Activation Regions

PostPosted: Thu Aug 18, 2011 6:30 am
by ESL
If I want a certain number of actors to be destroyed before moving to the next region, can I write:

if ("A","B", "C") == 0;
view.x=1273;
view.y=-8;

Re: Activation Regions

PostPosted: Thu Aug 18, 2011 6:34 am
by skydereign
Well not like that. But, if you want no A, B, or C actors in the region before jumping, you can use this.
Code: Select all
if(ActorCount("A")==0 && ActorCount("B")==0 && ActorCount("C")==0)
{
    view.x=1273;
    view.y=-8;
}

Re: Activation Regions

PostPosted: Thu Aug 18, 2011 6:45 am
by ESL
you rock dude!

Re: Activation Regions

PostPosted: Thu Aug 18, 2011 9:21 am
by ESL
I put that last script into the global code but there was no effect.

Re: Activation Regions

PostPosted: Thu Aug 18, 2011 10:04 am
by skydereign
If you mean the if statement with the ActorCount calls, it won't work because that is not what global code does. Global code is not executed every frame. That is to say the code you stuck there will never be triggered. To have parts of global code execute you need to create functions and call those from actor events. So, long story short you don't want to put them there. Instead you should put them in some actor event. For example if certain actors are being destroyed, which allows the player to move on, you might put it in the actors' (that need to be destroyed) Destroy Actor event. Of course the code will need to be changed to something like this.
A, B, and C -> Destroy Actor -> Script Editor
Code: Select all
int sum = ActorCount("A") + ActorCount("B") + ActorCount("C");

if(sum<=1)
{
    view.x=1273;
    view.y=-8;
}

Re: Activation Regions

PostPosted: Sat Aug 20, 2011 12:24 pm
by foleyjo
hey just jumping in here with a question.

When you move into a region (with the view) all the actors are created.
When you exit the region do all the actors get destroyed? If not do their events still take effect (eg if something had an xvelocity would it still be moving )
If so are they recreated the next time you enter that region?