Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
General
»
how i can move sprite with mouse,help ASAP please
Print
Pages: [
1
]
Author
Topic: how i can move sprite with mouse,help ASAP please (Read 2570 times)
0 Members and 1 Guest are viewing this topic.
Momentu
Newbie
Posts: 2
how i can move sprite with mouse,help ASAP please
«
on:
April 26, 2016, 06:23:45 pm »
i'am working on a chess project and i wanted to know how i can move the pieces with mouse to a certain coordinate,i only started learning sfml 3 weeks ago i'am still a beginner
Logged
eXpl0it3r
SFML Team
Hero Member
Posts: 11030
Re: how i can move sprite with mouse,help ASAP please
«
Reply #1 on:
April 26, 2016, 07:11:59 pm »
sf::Mouse::getPosition(window)
provides you the position of the mouse.
sprite.setPosition()
allows you to set the position of a sprite.
Logged
Official FAQ:
https://www.sfml-dev.org/faq.php
Official Discord Server:
https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog:
https://duerrenberger.dev/blog/
Momentu
Newbie
Posts: 2
Re: how i can move sprite with mouse,help ASAP please
«
Reply #2 on:
April 26, 2016, 07:17:05 pm »
I know the coordinates of the chess pieces but how i can write that if i press with the mouse on that coordinate
move this piece i tried to do it but failed.
Logged
Tukimitzu
Full Member
Posts: 117
Anti-Hero Member
Re: how i can move sprite with mouse,help ASAP please
«
Reply #3 on:
April 26, 2016, 11:04:59 pm »
Use sf::Event to read when the mouse button is pressed. See
detailed description
.
while window is open
handle window events (if piece is selected and mouse was pressed, update position)
other updates go here...
end while
Logged
@davi_doro
Pointless Wars Devlog
Print
Pages: [
1
]
SFML community forums
»
Help
»
General
»
how i can move sprite with mouse,help ASAP please