Hello all. I'm currently working on a program that's sort of like a drag-and-drop level editor. I'd like to be able to move the view around using WASD (which I have working), but I also have events that place objects in relation to the mouse's current position.
When I move the view at runtime, Mouse::getPosition() doesn't update to account for the fact that the view has moved. In other words, if I move the view 3 steps to the left and then drop an object, it drops it 3 steps to the right of where my mouse is.
I'm not sure that posting any particular code will help, as it seems more of a logical problem than a coding conflict, but here is the code for both operations:
if(sf::Mouse::isButtonPressed(sf::Mouse::Left) && keyDown == false)
{
mousePosition = sf::Mouse::getPosition(*App);
if(!pointManager->IsPoint(*App) && pointManager->GetNumLoopPoints()%2 != 0)
{
pointManager->AddPoint(new Point(mousePosition.x, mousePosition.y, "edge"));
}
keyDown = true;
}
and this:
if (Event.type == sf::Event::KeyPressed)
{
switch(Event.key.code)
{
//move the camera with WASD
case sf::Keyboard::W:
view.move(0, -4);
App->setView(view);
break;
case sf::Keyboard::S:
view.move(0, 4);
App->setView(view);
break;
Any insights would be very much appreciated!