O
oliverr
Guest
Hi,
I'm not sure if this is a bug or I am doing something incorrectly. Simple click and destroy instance code. Works as expected on desktop, but not in HTML export:
Desktop
HTML
2 objects, one to track the click and movement of the arrow, the other to just remove the instance of the created circle. Any help would be much appreciated!
The problem seems to relate to the instance_destory() in the obj_click_point step event. It's as if it is looking for the id of the object after it has been destroyed.
obj_arrow:
obj_click_point
I'm not sure if this is a bug or I am doing something incorrectly. Simple click and destroy instance code. Works as expected on desktop, but not in HTML export:
Desktop
HTML
2 objects, one to track the click and movement of the arrow, the other to just remove the instance of the created circle. Any help would be much appreciated!
The problem seems to relate to the instance_destory() in the obj_click_point step event. It's as if it is looking for the id of the object after it has been destroyed.
obj_arrow:
Code:
//Create event:
easingAmount = 0.01;
clicked_x = 0;
clicked_y = 0;
target_angle = 0;
target_object = "null";
Code:
//Step event:
if (mouse_check_button_pressed(mb_any)) {
clicked_x = mouse_x;
clicked_y = mouse_y;
var new_object = instance_create_layer(mouse_x, mouse_y, "Instances", obj_click_point);
target_angle = point_direction(x, y, mouse_x, mouse_y);
target_object = new_object.id;
}
if (target_object) {
//distance
var xDistance = target_object.x - x;
var yDistance = target_object.y - y;
var distance = sqrt(xDistance * xDistance + yDistance * yDistance);
if (distance > 150) {
x += xDistance * easingAmount;
y += yDistance * easingAmount;
} else {
x += xDistance * 0.05;
y += yDistance * 0.05;
}
//angle
var anglediff = angle_difference(image_angle, target_angle);
//incrementally change image angle
var pd = point_direction(x, y, target_object.x, target_object.y);
var dd = angle_difference(image_angle, pd);
image_angle -= min(abs(dd), 10) * sign(dd) * 0.5;
}
Code:
//Step event:
if(place_meeting(x,y,obj_arrow)){
score += 1;
instance_destroy();
//set the new target as the nearest point
obj_arrow.target_object = instance_nearest(obj_arrow.x, obj_arrow.y, obj_click_point);
}