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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Tixik

Pages: [1]
1
General / Re: Object positioning problem
« on: February 12, 2013, 06:08:03 pm »
Thanks a lot, turned out I missunderstood the use of view, I first rendered the objects and then applied the view, so It got the coords from previous state of view,but your solution is much better anyways.

2
General / Object positioning problem
« on: February 12, 2013, 05:16:18 pm »
Hi, so i have this Mario-like game...
main loop looks like

View view;
while(window.isOpen())
{
marioData.updatePlayer(View & view);
gameData.updateScore(View & view);
}

Please note that score and player are in different classes...
updatePlayer(View & view) just moves player left/right, depends on button pressed, and as the player moves, the view moves aswell - hence the view reference

updateScore(View & view) does this...
score_string.setPosition(700 + (view.getCenter().x - WIDTH/2 ) , 5);

where 700 and 5 are the on screen coords, but as the view moves, it has to move aswell in order to stay in the same place, that's when view.getCenter().x - WIDTH/2 comes into play , calculating x coord of view - screen width/2.

and my problem with this is that when i press the Left/Right button, the player, view and score moves, but score jumps like 10 pixels left/right, depends on the key pressed and stays 10pixels more left/tight than it should be, until the key is released and neither left and right key is pressed then it stays at correct position.

Please, I'm lost with this, what have I done wrong? Or is there a better way to make Score have absolute position on screen? Thanks in advance.

Pages: [1]