Need help with deleting A and B objects by clickin on A
by Vlad I · in Torque Game Builder · 11/18/2009 (8:13 am) · 7 replies
Hello
I'm trying to find a way to delete objects A and B by clicking on A.
In other words I need child to be deleted as soon as parent is clicked on.
What way would it be? I tried to mount B on A , it didnt work as I expected.
thank you
I'm trying to find a way to delete objects A and B by clicking on A.
In other words I need child to be deleted as soon as parent is clicked on.
What way would it be? I tried to mount B on A , it didnt work as I expected.
thank you
About the author
#2
And then I found a wayaround it and it works very well. I mount Box B on Box A in TGB it's all good, except that I'd like to add fading to both and the Box B doesnt inherit it if I add on Box A.
Here is my code
function BoxA::onAdd(%this)
{
%this.setUseMouseEvents( true );
}
function BoxA::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
{
%this.safeDelete();
}
What do you think Milan
11/18/2009 (6:00 pm)
The reason why I was asking about it was what direction should I follow to , it looks to me my problem has several solutions.And then I found a wayaround it and it works very well. I mount Box B on Box A in TGB it's all good, except that I'd like to add fading to both and the Box B doesnt inherit it if I add on Box A.
Here is my code
function BoxA::onAdd(%this)
{
%this.setUseMouseEvents( true );
}
function BoxA::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
{
%this.safeDelete();
}
What do you think Milan
#3
When you mount an object, you merely fixed that object's position to another object's position (and rotation of you select that option). True, you can set "inherit attributes" to "true", but here is what that means:
Whether or not to inherit certain attributes from the object this is being mounted to. The inherited attributes are: enabled, visible, paused, and flip.
Those 4 attributes ONLY.
I suggest you to download this: webclass.superquest.net/gamemaker-projects/Vickie%20Brown/documentation/referenc...
And keep it open in the background while you are developing, for all times! It may be very useful.
11/19/2009 (11:14 am)
I think that you have mixed up "classes" and inherited methods with "mounted objects" :)When you mount an object, you merely fixed that object's position to another object's position (and rotation of you select that option). True, you can set "inherit attributes" to "true", but here is what that means:
Whether or not to inherit certain attributes from the object this is being mounted to. The inherited attributes are: enabled, visible, paused, and flip.
Those 4 attributes ONLY.
I suggest you to download this: webclass.superquest.net/gamemaker-projects/Vickie%20Brown/documentation/referenc...
And keep it open in the background while you are developing, for all times! It may be very useful.
#4
Btw I came up with this code, but it doesnt work, though it looks to me ok, and the console doesnt show any errors. Why wouldnt it work any thoughts?
function BoxA::onAdd(%this)
{
%this.setUseMouseEvents( true );
}
function BoxA::onMouseDown(%this, %modifier, %worldPosition, %clicks)
{
if(isObject(%this.BoxA))
%this.BoxA.safedelete();
%this.BoxB.safedelete();
}
11/19/2009 (4:04 pm)
Thanks MilanBtw I came up with this code, but it doesnt work, though it looks to me ok, and the console doesnt show any errors. Why wouldnt it work any thoughts?
function BoxA::onAdd(%this)
{
%this.setUseMouseEvents( true );
}
function BoxA::onMouseDown(%this, %modifier, %worldPosition, %clicks)
{
if(isObject(%this.BoxA))
%this.BoxA.safedelete();
%this.BoxB.safedelete();
}
#5
11/19/2009 (6:30 pm)
Because %this IS BoxA.
#6
Damn, I havent thought about it, you are correct that was the root of my problem.
BoxA does get deleted, yet BoxB doesnt get deleted still, and now the console says:
"Unable to find object: 'BoxB' attempting to call function 'safedelete'
Here's how it looks now
function BoxA::onAdd(%this)
{
%this.setUseMouseEvents( true );
}
function BoxA::onMouseDown(%this, %modifier, %worldPosition, %clicks)
{
if(isObject(%this))
%this.safedelete();
BoxB.safedelete();
}
I have a feeling I need to define BoxB somewhere, unless something else
is missing, or it's just a wrong way to do it at all.
11/19/2009 (6:48 pm)
Thanks Milan !Damn, I havent thought about it, you are correct that was the root of my problem.
BoxA does get deleted, yet BoxB doesnt get deleted still, and now the console says:
"Unable to find object: 'BoxB' attempting to call function 'safedelete'
Here's how it looks now
function BoxA::onAdd(%this)
{
%this.setUseMouseEvents( true );
}
function BoxA::onMouseDown(%this, %modifier, %worldPosition, %clicks)
{
if(isObject(%this))
%this.safedelete();
BoxB.safedelete();
}
I have a feeling I need to define BoxB somewhere, unless something else
is missing, or it's just a wrong way to do it at all.
#7
Can anyone point me in the right direction?
Thank you
11/20/2009 (4:20 am)
Ok , I got it defined and now it works perfectly. Now the only propblem is to add fading to it or make BoxB inherit BoxA particle behavior (when you click on BoxA it safely delets itself and playes particle animation, I added this behavior in the editor)Can anyone point me in the right direction?
Thank you
Milan Rancic
How are you trying to accomplish this? What is your code?
Try removing objects onMouseUp event.
Use safeDelete() method.