is it being dragged? - *thanks Maqrkk*

9 posts

Flag Post

In the game im currently working on, i want the player to affected by an object (a spring). So basically, if it touches it, i want it to bounce up.

The spring is draggable (with the mouse) so i am using the start and stopDrag functions.

In my players code, i need to somehow check whether the spring is being dragged…

I am using external code (*.as) with classes if that makes any difference (im still learning AS)

Thanks,
Randomman159
Never Stop Developing…

 
Flag Post

Can’t you just use a boolean like isBeingDragged that you set to true when the startDrag function is called, and set to false when stopDrag is called?

 
Flag Post

I have this in a file called drag.as


class Drag extends MovieClip
{
public var DRAGGING = false;
private var DRAGGABLE = true;
function Drag()
{
onPress = doDrag;
}

private function doDrag():Void
{
if (DRAGGING == false && DRAGGABLE == true)
{
this.startDrag();
DRAGGABLE = false;
}
else
{
this.stopDrag();
}

}
}

then with the player i have this code:


if (root.SPRING.hitTest(x,y,true) && Math.abs(x – root.SPRING.x)<10 && _root.SPRING.DRAGGING == false)
{
vspeed = -16; //(WHICH I CHANGE THE _Y VALUE BY)
_root.SPRING.gotoAndPlay(2); //(MAKE IT SHOW THESPRINGING UP” ANIMATION)
}

It uses the spring even if it isn’t being dragged =(

any more help?

 
Flag Post

At no point do you change “DRAGGING”… And why are are you using caps for variables?

 
Flag Post

i don’t know why i use capitals… just a habit, and i only use it for some variables??? I understand my code, and don’t normally share it, so it doesn’t really matter…. yet

and thanks, can’t believe i didn’t notice that!

 
Flag Post

Capitals are normally reserved for CONSTant values, like Math.PI

camelCase is what’s normally used for function names and variables. CapitalizedCase is for class names.

 
Flag Post

You use capitals when you wish to yell. Kinda like the thread topic.
Why don’t you take your rude self somewhere else and demand help!

Freaking rude people always want to act entitled.

ps: your problem would be easy to fix so you shouldn’t have a problem finding help somewhere else.

 
Flag Post

and thanks, can’t believe i didn’t notice that!

Looks like he fixed it…

 
Flag Post

Create a var (somthing like “var dragging:Boolean = false”)

When spring is press dragging = true
When released dragging = false;