Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Set position depending on another entity  (Read 1612 times)

0 Members and 1 Guest are viewing this topic.

oOhttpOo

  • Newbie
  • *
  • Posts: 40
    • View Profile
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?  ;)

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
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?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
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.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor