|
|
|
|
9876.124023 9876.123456 |
ImageTop.getGlobalBounds().left
is the same as ImageTop.getPosition().x
.m_SpeedScalesMovingRow * dt.asSeconds()
could lead to problems if dt
happens to be too large. It could definitely lead to moving a little bit too far. Just to rule out that this is not the issue you might want to set it to the intended position directly.
SubZeroWins wrote: |
---|
When I get rid of the if() statement and just have the top image follow the bottom ... |
ImageTop.getGlobalBounds().left is the same as ImageTop.getPosition().x |
Follow? Doesn't removing the if() mean it will always move left at constant speed regardless of how ImageBottom moves? |
SubZeroWins wrote: |
---|
I am doing scaling and will be doing transformations on the image also down the road, so one needs to use ImageTop.getGlobalBounds().left to get the scaled or transformed versions of the coordinates and ImageTop.getPosition().x will not give the proper coordinates. |
ImageTop.getGlobalBounds().left
is equal to ImageTop.getPosition().x + 10
ImageTop.getGlobalBounds().top
is equal to ImageTop.getPosition().y - 5
ImageTop.setPosition(ImageTop.getGlobalBounds().left - 10, ImageTop.getGlobalBounds().top);
ImageTop.setPosition(ImageTop.getPosition().x, ImageTop.getPosition().y - 5);
SubZeroWins wrote: |
---|
it still misbehaves but takes a lot longer to catch them because it is moving so slowly and takes longer for me to see them. |
|
|
3.1415926536 3.14159265358979311600 3.1415926535897931159979634685441851615906 |
SubZeroWins wrote: |
---|
So what I think is happening is that the pixel moves to the left is not the same for the images with changes to dt and so the check <= does not occasionally fall through for a brief moment in time and it lags briefly behind and gives this jitter appearance. |
SubZeroWins wrote: |
---|
There is only 1 setPosition for the image, which is THE IMAGE, and you are going to want to use getGlobalBounds() for consistency so you can get the proper height & width if need be. But if you are not scaling/rotating, then one can use getPosition consistently. |
|
|
SubZeroWins wrote: |
---|
As if the dt for the ImageTop on occasions was above average and made the x-axis move faster than the check and then the check catches up again and continues moving the top image again. It is quick and quirky and like a fast skip in place on the x-axis. |
NOT dt = 0.016621 ImageTop marker if() check to move <= 1767.4 ImageBottom.left = 1846.53 ImageTop.left before move = 1827.4 NOT dt = 0.016574 ImageTop marker if() check to move <= 1767.4 ImageBottom.left = 1826.64 ImageTop.left before move = 1827.4 NOT dt = 0.016658 ImageTop marker if() check to move <= 1767.4 ImageBottom.left = 1806.65 ImageTop.left before move = 1827.4 NOT dt = 0.016613 ImageTop marker if() check to move <= 1767.4 ImageBottom.left = 1786.71 ImageTop.left before move = 1827.4 MOVE dt = 0.01672 ImageTop marker if() check to move <= 1767.4 ImageBottom.left = 1766.65 ImageTop.left before move = 1827.4 ImageTop.left after move = 1807.33 - 20.064 = 1787.27 MOVE dt = 0.016669 ImageTop marker if() check to move <= 1747.33 ImageBottom.left = 1746.65 ImageTop.left before move = 1807.33 ImageTop.left after move = 1787.33 - 20.0028 = 1767.33 MOVE dt = 0.016605 ImageTop marker if() check to move <= 1727.33 ImageBottom.left = 1726.72 ImageTop.left before move = 1787.33 ImageTop.left after move = 1767.4 - 19.926 = 1747.48 MOVE dt = 0.016724 ImageTop marker if() check to move <= 1707.4 ImageBottom.left = 1706.65 ImageTop.left before move = 1767.4 ImageTop.left after move = 1747.34 - 20.0688 = 1727.27 MOVE dt = 0.016703 ImageTop marker if() check to move <= 1687.34 ImageBottom.left = 1686.61 ImageTop.left before move = 1747.34 ImageTop.left after move = 1727.29 - 20.0436 = 1707.25 MOVE dt = 0.016582 ImageTop marker if() check to move <= 1667.29 ImageBottom.left = 1666.71 ImageTop.left before move = 1727.29 ImageTop.left after move = 1707.39 - 19.8984 = 1687.49 MOVE dt = 0.016697 ImageTop marker if() check to move <= 1647.39 ImageBottom.left = 1646.67 ImageTop.left before move = 1707.39 ImageTop.left after move = 1687.36 - 20.0364 = 1667.32 MOVE dt = 0.016654 ImageTop marker if() check to move <= 1627.36 ImageBottom.left = 1626.69 ImageTop.left before move = 1687.36 ImageTop.left after move = 1667.37 - 19.9848 = 1647.39 MOVE dt = 0.016713 ImageTop marker if() check to move <= 1607.37 ImageBottom.left = 1606.63 ImageTop.left before move = 1667.37 ImageTop.left after move = 1647.32 - 20.0556 = 1627.26 MOVE dt = 0.016695 ImageTop marker if() check to move <= 1587.32 ImageBottom.left = 1586.6 ImageTop.left before move = 1647.32 ImageTop.left after move = 1627.28 - 20.034 = 1607.25 MOVE dt = 0.016601 ImageTop marker if() check to move <= 1567.28 ImageBottom.left = 1566.68 ImageTop.left before move = 1627.28 ImageTop.left after move = 1607.36 - 19.9212 = 1587.44 MOVE dt = 0.016617 ImageTop marker if() check to move <= 1547.36 ImageBottom.left = 1546.74 ImageTop.left before move = 1607.36 ImageTop.left after move = 1587.42 - 19.9404 = 1567.48 MOVE dt = 0.01671 ImageTop marker if() check to move <= 1527.42 ImageBottom.left = 1526.69 ImageTop.left before move = 1587.42 ImageTop.left after move = 1567.37 - 20.052 = 1547.32 MOVE dt = 0.01669 ImageTop marker if() check to move <= 1507.37 ImageBottom.left = 1506.66 ImageTop.left before move = 1567.37 ImageTop.left after move = 1547.34 - 20.028 = 1527.31 MOVE dt = 0.016623 ImageTop marker if() check to move <= 1487.34 ImageBottom.left = 1486.71 ImageTop.left before move = 1547.34 ImageTop.left after move = 1527.39 - 19.9476 = 1507.45 MOVE dt = 0.016714 ImageTop marker if() check to move <= 1467.39 ImageBottom.left = 1466.65 ImageTop.left before move = 1527.39 ImageTop.left after move = 1507.34 - 20.0568 = 1487.28 MOVE dt = 0.016638 ImageTop marker if() check to move <= 1447.34 ImageBottom.left = 1446.69 ImageTop.left before move = 1507.34 ImageTop.left after move = 1487.37 - 19.9656 = 1467.41 MOVE dt = 0.016656 ImageTop marker if() check to move <= 1427.37 ImageBottom.left = 1426.7 ImageTop.left before move = 1487.37 ImageTop.left after move = 1467.38 - 19.9872 = 1447.4 MOVE dt = 0.016678 ImageTop marker if() check to move <= 1407.38 ImageBottom.left = 1406.69 ImageTop.left before move = 1467.38 ImageTop.left after move = 1447.37 - 20.0136 = 1427.36 MOVE dt = 0.016713 ImageTop marker if() check to move <= 1387.37 ImageBottom.left = 1386.63 ImageTop.left before move = 1447.37 ImageTop.left after move = 1427.31 - 20.0556 = 1407.26 MOVE dt = 0.016795 ImageTop marker if() check to move <= 1367.31 ImageBottom.left = 1366.48 ImageTop.left before move = 1427.31 ImageTop.left after move = 1407.16 - 20.154 = 1387.01 MOVE dt = 0.016521 ImageTop marker if() check to move <= 1347.16 ImageBottom.left = 1346.65 ImageTop.left before move = 1407.16 ImageTop.left after move = 1387.34 - 19.8252 = 1367.51 MOVE dt = 0.016672 ImageTop marker if() check to move <= 1327.34 ImageBottom.left = 1326.65 ImageTop.left before move = 1387.34 ImageTop.left after move = 1367.33 - 20.0064 = 1347.32 MOVE dt = 0.01659 ImageTop marker if() check to move <= 1307.33 ImageBottom.left = 1306.74 ImageTop.left before move = 1367.33 ImageTop.left after move = 1347.42 - 19.908 = 1327.51 MOVE dt = 0.016643 ImageTop marker if() check to move <= 1287.42 ImageBottom.left = 1286.77 ImageTop.left before move = 1347.42 ImageTop.left after move = 1327.45 - 19.9716 = 1307.48 MOVE dt = 0.01676 ImageTop marker if() check to move <= 1267.45 ImageBottom.left = 1266.65 ImageTop.left before move = 1327.45 ImageTop.left after move = 1307.34 - 20.112 = 1287.23 MOVE dt = 0.016589 ImageTop marker if() check to move <= 1247.34 ImageBottom.left = 1246.75 ImageTop.left before move = 1307.34 ImageTop.left after move = 1287.43 - 19.9068 = 1267.52 MOVE dt = 0.01678 ImageTop marker if() check to move <= 1227.43 ImageBottom.left = 1226.61 ImageTop.left before move = 1287.43 ImageTop.left after move = 1267.29 - 20.136 = 1247.16 MOVE dt = 0.016662 ImageTop marker if() check to move <= 1207.29 ImageBottom.left = 1206.62 ImageTop.left before move = 1267.29 ImageTop.left after move = 1247.3 - 19.9944 = 1227.31 MOVE dt = 0.016602 ImageTop marker if() check to move <= 1187.3 ImageBottom.left = 1186.69 ImageTop.left before move = 1247.3 ImageTop.left after move = 1227.38 - 19.9224 = 1207.46 MOVE dt = 0.016638 ImageTop marker if() check to move <= 1167.38 ImageBottom.left = 1166.73 ImageTop.left before move = 1227.38 ImageTop.left after move = 1207.41 - 19.9656 = 1187.45 MOVE dt = 0.016791 ImageTop marker if() check to move <= 1147.41 ImageBottom.left = 1146.58 ImageTop.left before move = 1207.41 ImageTop.left after move = 1187.26 - 20.1492 = 1167.11 MOVE dt = 0.016558 ImageTop marker if() check to move <= 1127.26 ImageBottom.left = 1126.71 ImageTop.left before move = 1187.26 ImageTop.left after move = 1167.39 - 19.8696 = 1147.52 MOVE dt = 0.016756 ImageTop marker if() check to move <= 1107.39 ImageBottom.left = 1106.6 ImageTop.left before move = 1167.39 ImageTop.left after move = 1147.29 - 20.1072 = 1127.18 MOVE dt = 0.016765 ImageTop marker if() check to move <= 1087.29 ImageBottom.left = 1086.48 ImageTop.left before move = 1147.29 ImageTop.left after move = 1127.17 - 20.118 = 1107.05 MOVE dt = 0.01652 ImageTop marker if() check to move <= 1067.17 ImageBottom.left = 1066.66 ImageTop.left before move = 1127.17 ImageTop.left after move = 1107.34 - 19.824 = 1087.52 ...........(continue) |
........(continue) MOVE dt = 0.016571 ImageTop marker if() check to move <= 1047.34 ImageBottom.left = 1046.78 ImageTop.left before move = 1107.34 ImageTop.left after move = 1087.46 - 19.8852 = 1067.57 MOVE dt = 0.016802 ImageTop marker if() check to move <= 1027.46 ImageBottom.left = 1026.61 ImageTop.left before move = 1087.46 ImageTop.left after move = 1067.3 - 20.1624 = 1047.13 MOVE dt = 0.016532 ImageTop marker if() check to move <= 1007.3 ImageBottom.left = 1006.77 ImageTop.left before move = 1067.3 ImageTop.left after move = 1047.46 - 19.8384 = 1027.62 MOVE dt = 0.016781 ImageTop marker if() check to move <= 987.458 ImageBottom.left = 986.638 ImageTop.left before move = 1047.46 ImageTop.left after move = 1027.32 - 20.1372 = 1007.18 MOVE dt = 0.016665 ImageTop marker if() check to move <= 967.321 ImageBottom.left = 966.64 ImageTop.left before move = 1027.32 ImageTop.left after move = 1007.32 - 19.998 = 987.325 MOVE dt = 0.016577 ImageTop marker if() check to move <= 947.323 ImageBottom.left = 946.747 ImageTop.left before move = 1007.32 ImageTop.left after move = 987.431 - 19.8924 = 967.539 MOVE dt = 0.016673 ImageTop marker if() check to move <= 927.431 ImageBottom.left = 926.74 ImageTop.left before move = 987.431 ImageTop.left after move = 967.423 - 20.0076 = 947.416 MOVE dt = 0.016789 ImageTop marker if() check to move <= 907.423 ImageBottom.left = 906.593 ImageTop.left before move = 967.423 ImageTop.left after move = 947.276 - 20.1468 = 927.13 MOVE dt = 0.016525 ImageTop marker if() check to move <= 887.276 ImageBottom.left = 886.763 ImageTop.left before move = 947.276 ImageTop.left after move = 927.446 - 19.83 = 907.616 MOVE dt = 0.017379 ImageTop marker if() check to move <= 867.446 ImageBottom.left = 865.908 ImageTop.left before move = 927.446 ImageTop.left after move = 906.592 - 20.8548 = 885.737 NOT dt = 0.015978 ImageTop marker if() check to move <= 846.592 ImageBottom.left = 846.734 ImageTop.left before move = 906.592 MOVE dt = 0.017188 ImageTop marker if() check to move <= 846.592 ImageBottom.left = 826.109 ImageTop.left before move = 906.592 ImageTop.left after move = 885.966 - 20.6256 = 865.34 |
MOVE dt = 0.017806 ImageTop marker if() check to move <= 1304.64 ImageBottom.left = 1301.98 ImageTop.left before move = 1364.64 ImageTop.left after move = 1343.27 - 21.3672 = 1321.91 NOT dt = 0.015526 ImageTop marker if() check to move <= 1283.27 ImageBottom.left = 1283.35 ImageTop.left before move = 1343.27 MOVE dt = 0.017363 ImageTop marker if() check to move <= 1283.27 ImageBottom.left = 1262.51 ImageTop.left before move = 1343.27 ImageTop.left after move = 1322.44 - 20.8356 = 1301.6 _______________________________________________________ MOVE dt = 0.016751 ImageTop marker if() check to move <= 1423.53 ImageBottom.left = 1423.3 ImageTop.left before move = 1483.53 ImageTop.left after move = 1463.42 - 20.1012 = 1443.32 NOT dt = 0.016526 ImageTop marker if() check to move <= 1403.42 ImageBottom.left = 1403.47 ImageTop.left before move = 1463.42 MOVE dt = 0.016911 ImageTop marker if() check to move <= 1403.42 ImageBottom.left = 1383.18 ImageTop.left before move = 1463.42 ImageTop.left after move = 1443.13 - 20.2932 = 1422.84 _______________________________________________________ MOVE dt = 0.017371 ImageTop marker if() check to move <= 1251.02 ImageBottom.left = 1249.64 ImageTop.left before move = 1311.02 ImageTop.left after move = 1290.17 - 20.8452 = 1269.33 NOT dt = 0.015957 ImageTop marker if() check to move <= 1230.17 ImageBottom.left = 1230.49 ImageTop.left before move = 1290.17 MOVE dt = 0.016674 ImageTop marker if() check to move <= 1230.17 ImageBottom.left = 1210.48 ImageTop.left before move = 1290.17 ImageTop.left after move = 1270.17 - 20.0088 = 1250.16 _______________________________________________________ MOVE dt = 0.016766 ImageTop marker if() check to move <= 1050.69 ImageBottom.left = 1050.35 ImageTop.left before move = 1110.69 ImageTop.left after move = 1090.57 - 20.1192 = 1070.45 NOT dt = 0.016481 ImageTop marker if() check to move <= 1030.57 ImageBottom.left = 1030.58 ImageTop.left before move = 1090.57 MOVE dt = 0.016832 ImageTop marker if() check to move <= 1030.57 ImageBottom.left = 1010.38 ImageTop.left before move = 1090.57 ImageTop.left after move = 1070.37 - 20.1984 = 1050.17 |
SubZeroWins wrote: |
---|
If you use sf::RectangleShape, as I have seen some code that does, then every frame before you use it you have to set it = getGlobalBounds() if you scaled/transformed the original image. So really you end up using global anyway. If you don't, then yea it will shift. The setting of sf::RectangleShape is very convenient if you have long class and vector calls, then you can just use Rect1.x instead of something like MyVeryLongClassName::MyVeryLongFuncCall.myVeryLongArray[i].getGlobalBounds().x |
SubZeroWins wrote: |
---|
But if the origin is changed, lets say in the middle of the image, then I would imagine getGlobalBounds().left or .top should reference from the middle? |
SubZeroWins wrote: |
---|
Does it really wander away with all this considered? |
|
|
SubZeroWins wrote: |
---|
combined with loss of precision can cause that stutter I imagine |
|
|
|
|
|
|
I have no idea what you're talking about. Are you perhaps confusing sf::RectangleShape with sf::FloatRec? sf::RectangleShape inherits (indirectly) from sf::Drawable and sf::Transformable just like sf::Sprite does. |
MOVE dt = 0.017806 ImageTop marker if() check to move <= 1304.64 ImageBottom.left = 1301.98 ImageTop.left before move = 1364.64 ImageTop.left after move = 1343.27 - 21.3672 = 1321.91 NOT dt = 0.015526 ImageTop marker if() check to move <= 1283.27<<<<<<<<<<<<<<<<<<<<<<<< ImageBottom.left = 1283.35<<<<<<<<<<<<<<<<<<<<<<<< ImageTop.left before move = 1343.27 MOVE dt = 0.017363 ImageTop marker if() check to move <= 1283.27 ImageBottom.left = 1262.51 ImageTop.left before move = 1343.27 ImageTop.left after move = 1322.44 - 20.8356 = 1301.6 _______________________________________________________ MOVE dt = 0.016751 ImageTop marker if() check to move <= 1423.53 ImageBottom.left = 1423.3 ImageTop.left before move = 1483.53 ImageTop.left after move = 1463.42 - 20.1012 = 1443.32 NOT dt = 0.016526 ImageTop marker if() check to move <= 1403.42<<<<<<<<<<<<<<<<<<<<<<<< ImageBottom.left = 1403.47<<<<<<<<<<<<<<<<<<<<<<<< ImageTop.left before move = 1463.42 MOVE dt = 0.016911 ImageTop marker if() check to move <= 1403.42 ImageBottom.left = 1383.18 ImageTop.left before move = 1463.42 ImageTop.left after move = 1443.13 - 20.2932 = 1422.84 _______________________________________________________ MOVE dt = 0.017371 ImageTop marker if() check to move <= 1251.02 ImageBottom.left = 1249.64 ImageTop.left before move = 1311.02 ImageTop.left after move = 1290.17 - 20.8452 = 1269.33 NOT dt = 0.015957 ImageTop marker if() check to move <= 1230.17<<<<<<<<<<<<<<<<<<<<<<<< ImageBottom.left = 1230.49<<<<<<<<<<<<<<<<<<<<<<<< ImageTop.left before move = 1290.17 MOVE dt = 0.016674 ImageTop marker if() check to move <= 1230.17 ImageBottom.left = 1210.48 ImageTop.left before move = 1290.17 ImageTop.left after move = 1270.17 - 20.0088 = 1250.16 _______________________________________________________ MOVE dt = 0.016766 ImageTop marker if() check to move <= 1050.69 ImageBottom.left = 1050.35 ImageTop.left before move = 1110.69 ImageTop.left after move = 1090.57 - 20.1192 = 1070.45 NOT dt = 0.016481 ImageTop marker if() check to move <= 1030.57<<<<<<<<<<<<<<<<<<<<<<<< ImageBottom.left = 1030.58<<<<<<<<<<<<<<<<<<<<<<<< ImageTop.left before move = 1090.57 MOVE dt = 0.016832 ImageTop marker if() check to move <= 1030.57 ImageBottom.left = 1010.38 ImageTop.left before move = 1090.57 ImageTop.left after move = 1070.37 - 20.1984 = 1050.17 |
|
|