(FDisplayObject displayObj)
| 198 | } |
| 199 | |
| 200 | public void draw(FDisplayObject displayObj) { |
| 201 | if (displayObj.getWidth() <= 0 || displayObj.getHeight() <= 0) { |
| 202 | return; |
| 203 | } |
| 204 | |
| 205 | final Rectangle parentBounds = bounds; |
| 206 | bounds = new Rectangle(parentBounds.x + displayObj.getLeft(), parentBounds.y + displayObj.getTop(), displayObj.getWidth(), displayObj.getHeight()); |
| 207 | if (!Dtransforms.isEmpty()) { //transform screen position if needed by applying transform matrix to rectangle |
| 208 | updateScreenPosForRotation(displayObj); |
| 209 | } else { |
| 210 | displayObj.screenPos.set(bounds); |
| 211 | } |
| 212 | |
| 213 | Rectangle intersection = Utils.getIntersection(bounds, visibleBounds); |
| 214 | if (intersection != null) { //avoid drawing object if it's not within visible region |
| 215 | final Rectangle backup = visibleBounds; |
| 216 | visibleBounds = intersection; |
| 217 | |
| 218 | if (displayObj.getRotate90()) { //use top-right corner of bounds as pivot point |
| 219 | startRotateTransform(displayObj.getWidth(), 0, -90); |
| 220 | updateScreenPosForRotation(displayObj); |
| 221 | } else if (displayObj.getRotate180()) { //use center of bounds as pivot point |
| 222 | startRotateTransform(displayObj.getWidth() / 2, displayObj.getHeight() / 2, 180); |
| 223 | //screen position won't change for this object from a 180 degree rotation |
| 224 | } |
| 225 | |
| 226 | displayObj.draw(this); |
| 227 | |
| 228 | if (displayObj.getRotate90() || displayObj.getRotate180()) { |
| 229 | endTransform(); |
| 230 | } |
| 231 | |
| 232 | visibleBounds = backup; |
| 233 | } |
| 234 | |
| 235 | bounds = parentBounds; |
| 236 | } |
| 237 | |
| 238 | private void updateScreenPosForRotation(FDisplayObject displayObj) { |
| 239 | tmp.set(bounds.x, regionHeight - bounds.y, 0); |
nothing calls this directly
no test coverage detected