I won't use Destroy-Create system for the teleport thing...
I would just change the Player x and y position.
For example, there're 3 doors...
"Door1" will send you to "Door2", "Door2" will send you "Door3", and "Door3" to "Door1"...
So, here's the code for each door...
Door1 -> Collision -> from Player -> Script Editor:
- Code: Select all
collide.x=Door2.x;
collide.y=Door2.y;
view.x=Player.x-320; //supposed you have 640 width
view.y=Player.y-320;
Door2 -> Collision -> from Player -> Script Editor:
- Code: Select all
collide.x=Door3.x;
collide.y=Door3.y;
view.x=Player.x-320; //supposed you have 640 width
view.y=Player.y-320;
Door3 -> Collision -> from Player -> Script Editor:
- Code: Select all
collide.x=Door1.x;
collide.y=Door1.y;
view.x=Player.x-320; //supposed you have 640 width
view.y=Player.y-320;
Those are the most unefficient way, but worth to try than stuck in a bug.
And here's the more efficient way. I will just clone the door, and make a library for the next-door-destination id.
Put this in global code:
- Code: Select all
#define door_total 6 //supposed you have 5 doors in total, I always use max_value+1 to avoid array out of bound
int next_door[door_total]={1,2,3,4,0};
It will connect:
Door.0 to Door.1
Door.1 to Door.2
Door.2 to Door.3
Door.3 to Door.4
Door.4 to Door.0
And put this in Door -> Collision -> From Player -> Script Editor:
- Code: Select all
Actor *check;
char str[32];
sprintf(str,"Door.%i",next_door[cloneindex]);
check=getclone(str);
collide.x=check->x;
collide.y=check->y;
view.x=Player.x-320;
view.y=Player.y-320;
With this method, you can have 999 doors without 999 codes for each door. Only use one code above to manage them all