[RESOLVED] Collision Enable Button

Non-platform specific questions.

[RESOLVED] Collision Enable Button

Postby raminkhan » Thu Jan 05, 2012 3:06 am

Hi I was wondering to know how can I make a Hit button like okay two objects pass by each other, but when you press the hit button I want them to destroy each other but if you don't press the hit button they just pass by.
Last edited by raminkhan on Wed Jan 11, 2012 6:51 am, edited 1 time in total.
raminkhan
 
Posts: 63
Joined: Mon Sep 12, 2011 3:35 pm
Score: 0 Give a positive score

Re: Collision Enable Button

Postby skydereign » Thu Jan 05, 2012 5:47 am

You'll need a global variable, in this case I'd name it something like collide_button. On the actual button's mouse button down event, set collide_button to 1. On it's mouse button up event, set it to 0. That way, in the collision event between the two actors you want to be able to destroy each other, you can do this.
Code: Select all
if(collide_button_state==1)
{
    DestroyActor("Collide Actor");
    DestroyActor("Event Actor");
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Collision Enable Button

Postby raminkhan » Sat Jan 07, 2012 5:01 am

You know why I disagree with this approach sky? because we have a button its a third party. Okay two other parties are the two balls. so with your code, it sounds like your setting the relations between the button and one of the balls which is not the case we want to enable the collision and destruction of two balls if the third party button is pressed. and no destruction of two balls if the button is not pressed.
raminkhan
 
Posts: 63
Joined: Mon Sep 12, 2011 3:35 pm
Score: 0 Give a positive score

Re: Collision Enable Button

Postby skydereign » Sat Jan 07, 2012 7:11 am

Well, if you can disagree with my approach, then we are on the right path. If at any time you see something that does not fit your setup, then by all means make it work. In this case though, I think you are misunderstanding me. collide_button_state is a global variable. That is to say that when you press the button, it sets a variable (you can see it as a condition in your game). While this variable is set, it will cause the collisions between your two ball actors. That if(collide_button_state==1) code is meant to be in the collisions between the two ball actors. The only thing that has to do with the button is the mouse button down and up events that set collide_button_state.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Collision Enable Button

Postby raminkhan » Sat Jan 07, 2012 7:18 am

yeah so sky here's what I did I made this variable collide_button_state and I made it to be integer and global so then I just setted up a collision event between the two colliding actors but I put your code on the button. so I think thats where I messed up right?
raminkhan
 
Posts: 63
Joined: Mon Sep 12, 2011 3:35 pm
Score: 0 Give a positive score

Re: Collision Enable Button

Postby skydereign » Sat Jan 07, 2012 7:23 am

Right... Just in case, here is a ged. The actor on the bottom left is the button.
Attachments
button.ged
(1.87 KiB) Downloaded 74 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest