Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // STEP EVENT
- // target initialized in the Create Event
- //Note that I have conversions from gui layer to in-room, but as I know that is all functioning,
- //I omitted it from here. To simplify just assume cx and cy are the mouse position relative to
- //what layer it is interracting with
- //ds_list creation
- var _list = ds_list_create();
- //fill ds_list with all objects at this position
- var _fill = instance_position_list(cx, cy, all, _list, false);
- //If there is more than 1 object (since cursor is 1 object always seen)
- if (_fill > 1)
- {
- //Loop through the list
- for (var i = 0; i < _fill; ++i;)
- {
- if instance_exists(_list[| i]) //If the instance in the list still exists
- { //and is not "uninteractable" like a camera, or the cursor itself
- if (_list[| i]) != id && !object_is_ancestor(_list[| i].object_index,par_oob)
- {
- if target != noone //If I was over something
- {
- if instance_exists(target) //and it still exists
- {
- if target.depth > _list[| i].depth //and it's deeper than my new target
- {
- target = _list[| i];//Make the less deep object my target
- }
- }
- }
- if target == noone //If I wasn't over something to begin with
- {
- target = _list[| i]; //Make the hovered object the target
- }
- //show_debug_message(_list[| i].id);
- }
- }
- }
- }
- else { target = noone; } //If it is just the cursor being seen, target noone
- //If my target does not exist within the list of objects I am touching, target noone
- if ds_list_find_index(_list,target) == -1 { target = noone; }
- ds_list_destroy(_list);//Cleanup
- //show_debug_message("target: " + string(target));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement