T2008
Member
I'm suddenly having a strange problem with my room movement. When going from one room to the next, I have an intersect boundary event in player object, that directs which room to goto based on the object compass (see below). In the object compass creation code, I define the room (ie west = rm_2) and place the obj_compass in each room. I got this from the Game Maker Apprentice Book. Every now and then, but not always, it will say the variable in object compass isn't defined when I change rooms. Any ideas would be greatly appreciated, as this is so frustrating???
Edit: I eliminated the obj_compass and changed north, west, east, south to global variables defined in the player begin step event (initialized in create event). The intersect boundary event of player is same as above except instead of obj_compass.south, etc, it says global.south, etc. Should I define the directions in the begin step event of player? or does it belong somewhere else. I assume that Begin Step is read before Intersect Boundary Event. Sample code of begin step event is below:
Code:
{
if ( x <= 0 )
{
x += room_width-(sprite_width);
room_goto(obj_compass.west);
}
if ( x >= room_width-sprite_width)
{
x -= room_width-(sprite_width);
room_goto(obj_compass.east);
}
if ( y <= 0 )
{
y += room_height-(sprite_height-110);
room_goto(obj_compass.north);
}
if ( y >= room_height)
{
y -= room_height-(sprite_height-70);
room_goto(obj_compass.south);
}
}
Code:
if (room = rm_1) {
global.east = rm_2;
}
if (room = rm_2) {
global.west = rm1;
}
Last edited: