Game Development Community


#1
03/03/2005 (3:35 am)
Nothing wrong with that code.

When you click the mouse and move, it produces "onMouseDragged()" or "onRightMouseDragged()" events, not "onMouseMove()" at that point. You can put the same code in the dragged call as well if you wish (example below).

Also, I'd definately recommend not splitting-up the X/Y components until you have to. No need doing more work and having more variables than you have to. Also, you don't need to store the players position or use globals to transfer stuff like this. Most of the time these variables will be out of date so they are just overhead and confusing.

Just use something like:-
// Mouse Move.
function sceneWindow2D::onMouseMove( %This, %Modifier, %WorldPosition, %MouseClicks )
{
    UpdatePlayer( %WorldPosition );
}

// Click and Drag.
function sceneWindow2D::onMouseDragged( %This, %Modifier, %WorldPosition, %MouseClicks )
{
    UpdatePlayer( %WorldPosition );
}

// Update Player.
function UpdatePlayer( %WorldPosition )
{
    myPlayer.setPosition( %WorldPosition );
}

// Where is my player?
echo( myPlayer.getPosition() );

- Melv.
#2
03/03/2005 (4:14 am)
Robert: Naughty boy. Look in the reference doc. ;)

As I mentioned in the post, there's a seperate right-mouse version of these calls.

- Melv.
#3
03/03/2005 (7:21 am)
Lol

Melv "Mother" May

:)

how could you ask for better support the guy is sick and still manages to answer every question lol
#4
03/03/2005 (10:20 am)
Hehe. Glad you appreciate the effort I'm putting in. :)

*sniff*

- Melv.