#1
|
|||
|
|||
![]()
i have created some codes which all uses different ways to retrieve the sprite position and i discovered that movesprite doesn't handle all those equally.
if you use spriteposint or spritex movesprite will floor the new position values (therefore moves the sprite in wrong direction), whereas spritepos and spritexint produces correct ones. just click around, follow the sprite and tell me your thoughts about it ![]() |
#2
|
|||
|
|||
![]()
Interesting discovery and it does the same here.
The saving fact is that although these are different, there isn't a need to use the different ones in a single scenario, but I guess you knew that and was just pointing the fact out that they are different. Wow, don't I go on after a beer :-) |
#3
|
|||
|
|||
![]()
Contrary to what the help file tells us (and what it's meant to be) SpriteX() seems to give back an integer value and SpriteXInt() the float value of the sprite's position. Alain did it wrong in his code obviously.
Besides this, the sprite is acting as one should expect, not moving to higher x or y positions, only moving to the lower ones if you retrieve the position as an integer. |
#4
|
|||
|
|||
![]()
i thought it would be something like this, but why moves it only with lower integer values?
does ppl handles them then as float again? |
#5
|
|||
|
|||
![]()
If you use your debugger you can see pretty clearly what is happening let' say using SpritePosInt():
Hope I could express myself clearly enough ![]() Edit: The simple Code:
if (wParam$>x$) x$++; else x$--; end; So the perfect solution would be Code:
if (wParam$>(x$+SpriteWidth(sp$)/2)) x$++; else x$--; end; Last edited by zehlein; 12-21-2008 at 09:11 AM. Reason: Appended code |
#6
|
|||
|
|||
![]()
so in short, ppl floors the decimal values to get them as integer and therefore prefers most time the smaller position?
that would make sense, thanks for your great help ![]() your other solutions might be only better if you don't care about straight lines as movement. |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|