J
JayR
Guest
I have a lighting system that creates a sprite on an Asset Layer.
The codes below are for items that emit light.
Create event:
Step event:
The code below is for the object ctrl_lighting.
Create event:
Now, I'm trying to get a mob to check if it's in the light or out of the light. How do I check for this collision? Any help is greatly appreciated. Thanks.
The codes below are for items that emit light.
Create event:
Code:
// === Emits Light Handling =========================
// ==================================================
// Layer id which light sprite draws on.
bp_light_emit = 0;
// Brightness intensity of the light.
bp_light_emit_intensity = 0;
// ==================================================
Code:
// For blueprints that emits light when on the ground.
if (blueprint_is_light_source(object_index) == 2) {
if (bp_light_emit == 0) {
bp_light_emit = layer_sprite_create(ctrl_lighting.light_layer, x, y, spr_light);
}
layer_sprite_xscale(bp_light_emit, blueprint_is_light_source(object_index, 0));
layer_sprite_yscale(bp_light_emit, blueprint_is_light_source(object_index, 0));
bp_light_emit_intensity = pulse(bp_light_emit_intensity, 0.6, 0.8, 0.25);
layer_sprite_alpha(bp_light_emit, bp_light_emit_intensity);
}
Create event:
Code:
// Initialize the light system.
// YouTube Tut: Simple lighting system for GMS2 - GMWolf
// https://www.youtube.com/watch?v=Un9DC0cTiP4
light_layer = layer_get_id("Lights");
var cam = view_camera[view_current];
light_surface = surface_create(camera_get_view_width(cam), camera_get_view_height(cam));
layer_script_begin(light_layer, lights_begin);
layer_script_end(light_layer, lights_end);