• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

How do I change the collision mask of an object through code?

D

Dusk Charmant

Guest
In my game, when the player object goes to the worldmap room, I change the sprite so that it is a small sprite instead of the main sprite used in towns etc. To achieve this, I do:

if (room == worldmap1){
sprite[RIGHT, MOVIE] = duskworldmap_right;
sprite[UP, MOVIE] = duskworldmap_up;
sprite[LEFT, MOVIE] = duskworldmap_left
sprite[DOWN, MOVIE] = duskworldmap_down
}else{
//Use other sprites as normal
sprite[RIGHT, MOVIE] = dusk_right;
sprite[UP, MOVIE] = dusk_up;
sprite[LEFT, MOVIE] = dusk_left
sprite[DOWN, MOVIE] = dusk_down

sprite[RIGHT, ATTACK] = sword_right;
sprite[UP, ATTACK] = sword_up;
sprite[LEFT, ATTACK] = sword_left
sprite[DOWN, ATTACK] = sword_down
}

However, the problem is that since it's the same object, the same collision based on the normal sprite is used. Instead, I want to have it so that when it changes the room to the world map the collision mask is changed to the size of the small sprite that walks around on the worldmap.

How exactly would I do this?
 
Top