Rects, Which ways is up?

sterlingy

Active Member
Licensed User
Longtime User
I've just noticed an odd thing.

I'm using GameView, and I am locked in portrait mode.

When I change the DestRect parameters for an object, it behaves properly, but when I read the parameters, it would appear that Left and Right are swapped with Top and Bottom?

The other thing I noticed, is that if I rotate a Rect, none of its Top, Bottom, Left or Right parameters change. That is not possible with anything other than a circle and Rects aren't circles.

What's going on here?

-Sterling
 

sterlingy

Active Member
Licensed User
Longtime User
Flip and Rotate properties doesn't affect the Left / Top properties.

The steps to draw a rectangle:
- Position it based on Left / Top / Right / Bottom properties
- Rotate it based on Rotate value
- Flip it based on Flip value

Okay, but there is some strangeness is the numbers. I logged the movement of the two sprites. The SafeZone was set to 0, so that number is irrelevant.

B4X:
Log("dLeft: " & MyRect.Left)
            Log("dRight: " & MyRect.Right)
            Log("dTop: " & MyRect.Top)
            Log("dBottom: " & MyRect.Bottom)
            
            Log("cLeft: " & outRect(0).Left & " with Safe: " & (outRect(0).Left - safeZoneX))
            Log("cRight: " & outRect(0).Right & " with Safe: " & (outRect(0).Right + safeZoneX))
            Log("cTop: " & outRect(0).Top & " with Safe: " & (outRect(0).Top - safeZoneY))
            Log("cBottom: " & outRect(0).Bottom & " with Safe: " & (outRect(0).Bottom + safeZoneY))
            Log("-----------------------")

And here is a snippet. Just look at the "c" values. This is an object that is moving vertically, therefore, the cLeft and cRight values should not change. But, they keep bouncing back and forth. I don't see that behavior when running the app.

dLeft: 160
dRight: 260
dTop: 1482
dBottom: 1672
cLeft: 667 with Safe: 667
cRight: 792 with Safe: 792
cTop: 602 with Safe: 102
cBottom: 727 with Safe: 1227
-----------------------
dLeft: 222
dRight: 272
dTop: 598
dBottom: 723
cLeft: 160 with Safe: 160
cRight: 260 with Safe: 260
cTop: 1527 with Safe: 1527
cBottom: 1717 with Safe: 1717
-----------------------
dLeft: 160
dRight: 260
dTop: 1532
dBottom: 1722
cLeft: 667 with Safe: 667
cRight: 792 with Safe: 792
cTop: 602 with Safe: 102
cBottom: 727 with Safe: 1227
-----------------------
dLeft: 232
dRight: 282
dTop: 581
dBottom: 706
cLeft: 160 with Safe: 160
cRight: 260 with Safe: 260
cTop: 1577 with Safe: 1577
cBottom: 1767 with Safe: 1767
-----------------------
dLeft: 160
dRight: 260
dTop: 1582
dBottom: 1772
cLeft: 667 with Safe: 667
cRight: 792 with Safe: 792
cTop: 602 with Safe: 102
cBottom: 727 with Safe: 1227
-----------------------
dLeft: 242
dRight: 292
dTop: 563
dBottom: 688
cLeft: 160 with Safe: 160
cRight: 260 with Safe: 260
cTop: 1627 with Safe: 1627
cBottom: 1817 with Safe: 1817
-----------------------



-Sterling
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…