Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Graphics
»
Set position depending on another entity
Print
Pages: [
1
]
Author
Topic: Set position depending on another entity (Read 1603 times)
0 Members and 1 Guest are viewing this topic.
oOhttpOo
Newbie
Posts: 40
Set position depending on another entity
«
on:
May 12, 2015, 09:04:31 pm »
Hi
I want to set the position of a shape to the same (or roughly the same, doesn't really matter) position of another shape. However I cant just do .setPosition(points) as the shape is often moving, therefore I would like to set it to same position as the other shape (every time it is triggered). I tried to set the position to the other shape's global bounds. I attempted "shape1.setPosition(shape2gbs)". How can I do this?
Logged
shadowmouse
Sr. Member
Posts: 302
Re: Set position depending on another entity
«
Reply #1 on:
May 12, 2015, 09:13:38 pm »
Have you tried using shape1.setPosition(shape2.getPosition()) at the start and whenever shape2 moves?
Logged
zsbzsb
Hero Member
Posts: 1409
Active Maintainer of CSFML/SFML.NET
Re: Set position depending on another entity
«
Reply #2 on:
May 12, 2015, 09:14:47 pm »
There is no way to automatically move one shape when another moves, so you must do as shadowmouse said and move shape1 whenever shape2 moves.
Logged
Motion / MotionNET
- Complete video / audio playback for SFML / SFML.NET
NetEXT
- An SFML.NET Extension Library based on
Thor
Print
Pages: [
1
]
SFML community forums
»
Help
»
Graphics
»
Set position depending on another entity