Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi. I have a question about C++. The requirement is: Draw shape at the current mouse position by responding to MouseMoved events. This is what

Hi. I have a question about C++.

The requirement is: Draw shape at the current mouse position by responding to MouseMoved events.

This is what I have so far (Only the part relate to this question):

CODE:

sf::RectangleShape rectangle; rectangle.setSize(sf::Vector2f(120.f, 50.f)); rectangle.setPosition(200,200);

if (event.type == sf::Event::MouseMoved) {

std::cout << " X = " << event.mouseMove.x << ", Y =" <

rectangle.getPosition().x + 0, rectangle.getPosition().y + 0);

}

I assumed it has sth to do with the getPosition function, but I don't know how to apply it. Some details would be appreciated!!!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions