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

Author Topic: ConvertCoords not working as expected  (Read 3890 times)

0 Members and 1 Guest are viewing this topic.

Ezbez

  • Newbie
  • *
  • Posts: 10
    • View Profile
ConvertCoords not working as expected
« on: August 04, 2009, 11:37:43 pm »
I'm trying to place a circle at the mouse coordinates. I read in the mouse coordinates and pass them through RenderWindow::ConvertCoords(), and yet my results aren't what I expect. The circle is drawn a constant 1/2 width and 1/2 height down and to the right of the mouse. It does the same if I don't use the ConvertCoords. Here's the code (in PySFML):

Code: [Select]
from PySFML import sf

window = sf.RenderWindow( sf.VideoMode(800,600), "SFML Program" )
input = window.GetInput()

playerGfx = sf.Shape.Circle(400,300, 8, sf.Color.White)

running = True
while running:
event = sf.Event()
while( window.GetEvent(event) ):
if ( event.Type == sf.Event.Closed ):
running = False

mPos = window.ConvertCoords( input.GetMouseX(), input.GetMouseY() )

window.Clear()

playerGfx.SetPosition(mPos[0], mPos[1])
window.Draw( playerGfx )

window.Display()

window.Close()


Am I misunderstanding ConvertCoords or is it misbehaving?

Ezbez

  • Newbie
  • *
  • Posts: 10
    • View Profile
ConvertCoords not working as expected
« Reply #1 on: August 04, 2009, 11:40:20 pm »
Oh man. The instant I post I realize what the problem is. Just gotta change the call to sf.Circle to sf.Circle(0,0, 8, sf.Color.White). Not a problem with ConvertCoords at all!

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
ConvertCoords not working as expected
« Reply #2 on: August 05, 2009, 01:16:25 am »
Quote from: "Ezbez"
The instant I post I realize what the problem is.


I'm familiar with that phenomenon, really annoying isen't it :D

 

anything