• 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!

Drawing sprites in different layer than the object is in

Hiya!

I am making a top-down sci-fi shooter.

I have a lighting layer (instance layer), where all sprites subtracts from a dark surface making a lighting effect. I used a tutorial to create that.

I want my player shots to draw a small sprite or sphere in the lighting room, but still keep the player bullet in the

I really don't want to create an object in the lighting layer to stay untop of the bullet, since it will get hard to control and use extra ressources. Unless there's a really easy way to connect the lighting object with the bullet object, so it destroys when the bullet object destroys.

Atm I create objects from the player, when the player creates a bullet or some sort, and then destroy the objects soon after with an alarm, so the light don't continue when the bullet hits a wall or enemy. But this is really not a good solution and works more like lighting from the weapons rather then the bullets.

I've tested the following code, but it crashes my game and doesn't really seem right:
GML:
layer_add_instance("Lights",self);
draw_rectangle(x,y,x+100,y+100,false);
layer_add_instance("PlayerBullets",self);
Screenshot attached. The robot with the light-saber kinda thing to the right is the player. The vast amount of blue/cyan bullets he's firing is what I want to create a small sprite on the Lights layer.

nolightsonshots.jpg
 
Assuming you have some kind of object in that layer doing all the work...

with (obj_bullet) draw_sprite(sprite,0,x,y);

That will draw whatever sprite you want at the x and y of each bullet. You might have to adjust the values to account for views/surfaces.
Thanks. Worked like a charm :D
 
Top