Page 1 of 2
how to stop draging ball on left mouse button relase ?
Posted:
Sun May 14, 2006 11:20 am
by sali11
Hi all,
Im trying to drag a ball on my screen, by clicking on the left mouse button. I managed to add the drag event and it worked however, the ball gets stuck to the mouse and wont let go when I release the mouse button.
Dose any one know how to stop the draging when the left mose key is released?
iv been searching throught the forums for any similer problem and fund stuff, but they dont say how to stop the drag on release. Im not using any scrips at the moment.
any ideas
Posted:
Sun May 14, 2006 1:07 pm
by Game A Gogo
do this insted, on mouse button down event, do a script:
- Code: Select all
Ballfollow=1;
dont forget to create the var named "Ballfollow"
then on draw event, do this script:
- Code: Select all
if(Ballfollow==1)
{
x=xmouse;
y=ymouse;
}
and then on mouse button up event do this code:
- Code: Select all
Ballfollow=0;
Posted:
Sun May 14, 2006 3:28 pm
by sali11
Hi Game a Gogo,
when I put the code:
Ballfollow=1;
on the balls mouse button down event I get an error message saying:
Error line 1: Incompatible types: cannot convert from 'const int' to 'Identifier'
Also where and how do I add the var named Ballfollow? does it go on the ball draw event? and how is it written?
when I add the code:
if(Ballfollow==1)
{
x=xmouse;
y=ymouse;
}
I get anoter error message:
Error line 2: Undeclared identifir Ballfollow
Warning line 2: Possible non relational operation
Error line 2: Undefined type for relational operation
could you explain how to apply your code step by step? I am new to this so im lerning. thanks for your help
[/code]
Posted:
Sun May 14, 2006 7:15 pm
by Game A Gogo
when you will add the var, everything will be ok
how to do it:
firts when your in the scrit editor, just beside the variable/action buttons, there a Variable button, click on that one, then click on the add button, in the name entry, type Ballfollow and click add.
and thats it, youv just created a new Variable, and it will be useful in the furture!.
Posted:
Mon May 15, 2006 2:52 pm
by sali11
ok cool. ill try that out when i get home.
I was looking at the demo 'The Core' and in that you have the drag function I want, I applyed it and it works, however there were still a couple of bugs in it when I tested it. Ill try your way and see which is best
Thanks for your help
Posted:
Mon May 15, 2006 11:00 pm
by sali11
ok, i have added the var as you said and done every thing els. and now im not getting any error messages.
when i test it how ever, something very strange is happening. The ball ends up being at he bottem right of the screen but still reacts to the draging, So i drag he mouse, and the ball moves according to it, but at the differen location (not under the cursor). Then when I let the ball go, it slides back into the boundry it was suppose to be in,
I think i have made a mistake some were, can you explain it again step by step and ill try again. In as much detail as you can provide, thanks for your help
Posted:
Mon May 15, 2006 11:20 pm
by Game A Gogo
on the x and y follow thingy, just add half of the screen!
EX:
if you have a screen size of 240x320 the the script should be:
- Code: Select all
x=xmouse-120;
y=ymouse-160;
That should do it, sorry
Posted:
Mon May 15, 2006 11:55 pm
by DilloDude
Or set xscreen = xmouse, yscreen = ymouse. xmouse and ymouse are relative to the view's position.
Posted:
Tue May 16, 2006 9:15 am
by sali11
ok cool, ill try that when i get home. and ill try Game a Gogo's way as well to see which is best. thanks for your help, both of you
Posted:
Tue May 16, 2006 10:12 pm
by sali11
Hi, I ended up using DilloDude's code because the other way was not working out for me. The ball is getting draged now, however there is a strange problem with it.
As soon as I start dragging it, the ball slides away a bit
iv done all sorst of things with the code to fix it but it just wont work.
I dont understand why there is no way of just disabeling a simple follow mouse event that is drag enabled. there must be a way to do that when the left mouse button is released?
Posted:
Tue May 16, 2006 10:42 pm
by Game A Gogo
im sorry, i cant help you anyfurtherr...
Posted:
Wed May 17, 2006 12:38 am
by makslane
If you use the drag option in the 'Mouse Button Down' event, the drag will stop when you release the mouse button.
If you set the 'Follow Mouse' action, just, in a 'Mouse Button Up' event, set the 'Follow Mouse' action with Axis option set to none.
Posted:
Wed May 17, 2006 8:16 am
by sali11
ok, cool. when I set the drag option, i end up getting a list of events that I have to choose from, and the only event that is close to what I want to do is the follow mouse. what would i select to just geep it at drag, because drag is not in the list as such? thanks for your help
Posted:
Wed May 17, 2006 12:37 pm
by makslane
Set the drag option, and use some action with no effects like 'Visible State' with state enable.
Posted:
Wed May 17, 2006 1:32 pm
by sali11
ok cool,ill try that tonight, one thing I noticed is that if I drag the ball past the wall boundry, it passes through the wall, is there any way of making sure it wont pass through the wall when im dragging it?
thanks for your help