Mouse control
6 posts • Page 1 of 1
Mouse control
If there is any detection of mouse "mousedown", like key "mouseleft"?
Thanks beforehand!
Thanks beforehand!
-
Nait - Posts: 224
- Joined: Fri Oct 30, 2009 1:56 am
- Location: Eastern Russia, Vladivostok
Re: Mouse control
I already got an idea for a code. I'll post it when it's ready.
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Mouse control
What do you mean mouse down? Mouse key down or mouse movement?
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: Mouse control
Oh, I didn't think of that. I thought you want to get the mouse movement.
If you want something that detects if a mouse button is pressed you can do that with mechanics in algodoo. For the movmement I made this:
If you want something that detects if a mouse button is pressed you can do that with mechanics in algodoo. For the movmement I made this:
- Code: Select all
Scene.my.p1 := [0, 0];
Scene.my.move := "";
Scene.my.mousemovement :=
{
posdiff := app.mousepos - scene.my.p1;
scene.my.p1 = app.mousepos;
move := "";
(posdiff(0) ^ 2 + posdiff(1) ^ 2) ^ 0.5 > 0.01 ? {
a := math.acos(posdiff(0) / (posdiff(0) ^ 2 + posdiff(1) ^ 2) ^ 0.5);
posdiff(1) < 0 ? {a = 2 * math.pi - a} : {};
math.or(a <= math.pi / 4, a > 7 * math.pi / 4) ? {scene.my.move = "right"} : {a <= 3 * math.pi / 4 ? {scene.my.move = "up"} : {a <= 5 * math.pi / 4 ? {scene.my.move = "left"} : {a <= 7 * math.pi / 4 ? {scene.my.move = "down"} : {}}}}
} : {scene.my.move}
}
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
Re: Mouse control
I mean mouse click, I ask becouse I know that in Visual Basic it can identify if button is pressed or if it goes back after click.
-
Nait - Posts: 224
- Joined: Fri Oct 30, 2009 1:56 am
- Location: Eastern Russia, Vladivostok
Re: Mouse control
Something like this?
If you want to check how it works look at the left hand side. There's an invisible collision checker.
If you want to check how it works look at the left hand side. There's an invisible collision checker.
- Code: Select all
Scene.my.presstime := -1;
Scene.my.mouseleft := {(sim.time - scene.my.presstime) < 0.05 ? {true} : {false}};
Scene.my.presstime2 := -1;
Scene.my.mouseright := {(sim.time - scene.my.presstime2) < 0.05 ? {true} : {false}}
-
KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
6 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 3 guests