help removing control
jameslavis
Member Posts: 15
hey folks, new to gamesalad but have a coding background of sorts. I'm looking to work with drag and drop games. So I'm using an object with constraints to be draggable. What I can't seem to do is remove the ability to drag once the object hits another. So I have a collide rule, but how can I take away the ability for it to move?
Comments
Give the actor a self attribute, let's call it 'X'
When X is true and touch is pressed constrain actor to mouse.
When actor collides with obstacle/enemy change X to false.
Ok so you'll have to bare with me a bit, I've used a number of programs and get the boolean theory but you'll have to help me translate.
I see you add an attribute to the actor in the properties panel, and make it a boolean. So if I create a rule that has the constraint aspects to drag, how do I connect the boolean to it? is it another behavior in the rule? an expression?
Also any great tutorials would be amazing
The little + in a circle over on the right at the top of the rule adds another condition to the rule.
ok so I have a double condition rule, with the mouse down triggering and the attribute changing to true. so that works. Now in the cancellation process, rule would be something like mouse up, boolean goes to false, then do I have to have the two behaviors in there as well?
or would I use the "otherwise" aspect of a rule. that's a new one to me. thinking it's like an else in Actionscript 3
ok so I think I have it. I have the attribute set to true and it allows the drag, when false it sets the x and y to be self. So it stays in place. A mouse down and up change the value of the boolean. Is there a more concise way of doing this?
a second question. If I drop the object on another, is there a way I can remove any mouse interaction ability (not making it able to be dragged)? I'm thinking it could be a new attribute and when a collide makes it happen lock the x and y to that of the drop space. thoughts?
I'd keep it simple, just have a switch (an attribute) that when off stops the actor from being able to be moved.
Like this:
it still initializes when you click back on it. so what I'm trying to do is have a drop target (another actor). so when I drag and drop the main actor, I want it to kill it's ability to be dragged when it's placed on the target. I'll have a few of these so it'll likely have to be an attribute confined to each actor.
can you upload files here?
The above code (the screenshot) works just fine, did you try it, if you did can you take a screenshot of the rules you used ?
moron moment. Ok had the wrong value for the last change attribute. Your created attribute of "X" looks as if it's a boolean (which is what I've been trying). So you set it to "true" when pressed. That I get. I was switching it to false with no luck. So what does the "0" represent? Why won't a "false" work. I've always used true/false aspects of booleans.
also socks can you recommend any killer tutorials? Just need to get my knowledge transferred to this program and it'd be great to spend some times in the depths of this program!
Yes, it's a boolean.
No, it is not changed by something being pressed, the attribute starts out as true (see the attribute in the left hand column, it is ticked, that means it is true) and when it collides with an object it becomes false.
0 represents 'false'.
To be honest I'm not the person to ask, I don't really use or make tutorials, I think if you search around there are a lot of good tutorials on just about every GS subject out there.