object inherits events after changing it to another object?

V

vidokas

Guest
Hi.
I have 3 objects.
obj_parrent, obj_tree and obj_burning
obj_tree and obj_burning is child's of obj_parrent

------------------------------------------------------------------------
obj_tree
Create Event
alarm[0] = 15;


mouse press event
instance_change(obj_burning,true)

Alarm[0] event
if position_meeting(x - 32, y, obj_burning) instance_change(obj_burning,true);
if position_meeting(x + 32, y, obj_burning) instance_change(obj_burning,true);
if position_meeting(x, y + 32, obj_burning) instance_change(obj_burning,true);
if position_meeting(x, y - 32, obj_burning) instance_change(obj_burning,true);
alarm[0] = 15;

--------------------------------------------------------

obj_burning
Create Event
alarm[0]=90;

Alarm[0] Event

with (self)
{
instance_destroy();
}
--------------------------------------------


I have 3 objects next to each other and I change first obj_tree into obj_burning by pressing mouse button on him.
then after 15 steps next obj_tree is changed into obj_burning because of
if position_meeting(x - 32, y, obj_burning) instance_change(obj_burning,true); command

But all obj_burning are destroyed in 15 steps except first one. First one will be destroyed only after 90 steps AFTER ALL OTHER other obj_burning are destroyed


Example:
There is 3 objects obj_tree next to each other. 1-2-3 (first-second-third)
I change first obj_tree into obj_burning
-15steps later
second obj_tree is changed into obj_burning
-30 steps later
third obj_tree is changed into obj_burning
second obj_tree is destroyed (it should be destroyed after 90 steps, not 30, because alarm[0] on obj_burning is 90, not 30. alarm[30] was on obj_tree.
-45 steps later
third object_burning is destroyed (it should be destroyed after 135 steps (45+90))
-135 steps later
first obj_burning is destroyed (it should be destroyed 90 steps later, not 135)
WHERE IS THE BUG?

P.S. I changed obj_burning alarm[0] to alarm[1] and then problem disappeared.
But still why it doesn't work correctly with alarm[0]?
 
Last edited by a moderator:
V

vidokas

Guest
I know what parent and child system is.
I rewrote topic little bit, maybe now it's more clear.
 
Last edited by a moderator:
Top