Touch events. We all use them for area transitions and as triggers for cut scenes and what not, but as a map grows so does the number of these little insubstantial objects that the program must keep track of. Too many and we get laggy gameplay which can be annoying if not utterly frustrating. This tutorial is meant to discuss a strategy of reducing the number of these touch events by using the map grid point numbers as conditionals on one governing parallel process. Thereby reducing what could be thirty or forty touch events to one parallel process event that does all of the work with far less lag.
Here's an example of an over evented map with lag.
http://www.box.net/index.php?rm=box_v2_ ... _133909819
On this map there are 100 + touch events used to cover all of the edges so that the player will transfer back towards the center of the map with each touch. The result is lag, and we don't even have anything on here worth looking at or playing through. The question becomes how can we fix it.
Here's now the same map with only one parallel process achieving the same results.
http://www.box.net/index.php?rm=box_v2_ ... _133909975
No lag at all, but I still have a wide range of map points that transfer me back to the center of the map. All the same work as the first map, but with only one event.
How to do this
It's actually quite simple. First we need to set up a parallel process event. Then do the following on the event screen:
Declare variables.
Those two commands will constantly update those two variables to be equal to wherever you move the player on the map.
Now to do something with them by adding the controlling conditionals (do not use the else handler):
So, what does that mean? Well the three conditions are working together. It is only when the variable Player X is equal to zero and player y is between 1 and 38 that the area transfer will happen. Conditionals could be used to make narrow lines of event as well as cubic regions or one simple grid point. This approach can be easily used to replace most area transition events and cut scene triggers. All while reducing the amount of events that produce lag on the system.
Here's an example of an over evented map with lag.
http://www.box.net/index.php?rm=box_v2_ ... _133909819
On this map there are 100 + touch events used to cover all of the edges so that the player will transfer back towards the center of the map with each touch. The result is lag, and we don't even have anything on here worth looking at or playing through. The question becomes how can we fix it.
Here's now the same map with only one parallel process achieving the same results.
http://www.box.net/index.php?rm=box_v2_ ... _133909975
No lag at all, but I still have a wide range of map points that transfer me back to the center of the map. All the same work as the first map, but with only one event.
How to do this
It's actually quite simple. First we need to set up a parallel process event. Then do the following on the event screen:
Declare variables.
Code:
Control Variables: [001: Player X] == Player's Map X
Control Variables: [002: Player Y] == Player's Map Y
Those two commands will constantly update those two variables to be equal to wherever you move the player on the map.
Now to do something with them by adding the controlling conditionals (do not use the else handler):
Code:
Conditional Branch:: Variable [Player X] == 0
Conditional Branch:: Variable [Player Y] >= 1
Conditional Branch:: Variable [Player Y] <= 38
Transfer Player: [001;map001], (11,8)
Branch End
Branch End
Branch End