how to stop draging ball on left mouse button relase ?

Game Editor comments and discussion.

how to stop draging ball on left mouse button relase ?

Postby sali11 » Sun May 14, 2006 11:20 am

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 :?: :?: :?: :?:
sali11
 
Posts: 37
Joined: Sun Apr 30, 2006 6:51 pm
Location: LONDON
Score: 0 Give a positive score

Postby Game A Gogo » Sun May 14, 2006 1:07 pm

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;
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby sali11 » Sun May 14, 2006 3:28 pm

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]
sali11
 
Posts: 37
Joined: Sun Apr 30, 2006 6:51 pm
Location: LONDON
Score: 0 Give a positive score

Postby Game A Gogo » Sun May 14, 2006 7:15 pm

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!.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby sali11 » Mon May 15, 2006 2:52 pm

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 :)
sali11
 
Posts: 37
Joined: Sun Apr 30, 2006 6:51 pm
Location: LONDON
Score: 0 Give a positive score

Postby sali11 » Mon May 15, 2006 11:00 pm

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, :shock: 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
sali11
 
Posts: 37
Joined: Sun Apr 30, 2006 6:51 pm
Location: LONDON
Score: 0 Give a positive score

Postby Game A Gogo » Mon May 15, 2006 11:20 pm

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 :D
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby DilloDude » Mon May 15, 2006 11:55 pm

Or set xscreen = xmouse, yscreen = ymouse. xmouse and ymouse are relative to the view's position.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby sali11 » Tue May 16, 2006 9:15 am

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
sali11
 
Posts: 37
Joined: Sun Apr 30, 2006 6:51 pm
Location: LONDON
Score: 0 Give a positive score

Postby sali11 » Tue May 16, 2006 10:12 pm

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 :cry: 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? :x :(
sali11
 
Posts: 37
Joined: Sun Apr 30, 2006 6:51 pm
Location: LONDON
Score: 0 Give a positive score

Postby Game A Gogo » Tue May 16, 2006 10:42 pm

im sorry, i cant help you anyfurtherr...
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby makslane » Wed May 17, 2006 12:38 am

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.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby sali11 » Wed May 17, 2006 8:16 am

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
sali11
 
Posts: 37
Joined: Sun Apr 30, 2006 6:51 pm
Location: LONDON
Score: 0 Give a positive score

Postby makslane » Wed May 17, 2006 12:37 pm

Set the drag option, and use some action with no effects like 'Visible State' with state enable.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby sali11 » Wed May 17, 2006 1:32 pm

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 :D
sali11
 
Posts: 37
Joined: Sun Apr 30, 2006 6:51 pm
Location: LONDON
Score: 0 Give a positive score

Next

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest