Hi everyone, I really burned a few brain cells on this one but I just don't get it!
My game screen is 1024x768 with SetOrigin set 0,0
I have a single object at let's say x 300 and y 300
I wrote a tiny bit of code that when the mouse is on the edges of the screen it scrolls the map. So, when I have the mouse on the left hand side, I use the SetOrigin command to subtract a set number from x, so one scroll, X is now at -20 and then the screen gets redrawn. The actual object coordinates aren't changed.
Here is what I don't understand, the object is moving left instead of right! If the x origin is -20, shouldn't the object position move to the right by 20 pixels?
If I keep scrolling, the x origin is -300 but yet the object is drawn right up against the left edge of the screen, which I don't understand because shouldn't it be drawn on the right side of the screen instead?
The point of this is that I only draw what is visible on the screen, based on Origin coordinates relative to object coordinates.
Any anyone shed some light on this for me? Thanks in advance, hopefully I explained it well enough.
|