Skip to content

Commit

Permalink
Difference whether to apply transformation from scene or from parent …
Browse files Browse the repository at this point in the history
…entity
  • Loading branch information
Reco1I committed Dec 29, 2024
1 parent c0ccd9a commit 3fdc324
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/com/reco1l/andengine/EntityCollision.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object EntityCollision {
private val vertices = FloatArray(8)


fun contains(entity: ExtendedEntity, x: Float, y: Float): Boolean {
fun contains(entity: ExtendedEntity, x: Float, y: Float, fromScene: Boolean): Boolean {

val left = 0f
val top = 0f
Expand All @@ -29,7 +29,11 @@ object EntityCollision {
vertices[6 + VERTEX_INDEX_X] = left
vertices[6 + VERTEX_INDEX_Y] = bottom

entity.getLocalToSceneTransformation().transform(vertices)
if (fromScene) {
entity.localToSceneTransformation.transform(vertices)
} else {
entity.localToParentTransformation.transform(vertices)
}

return ShapeCollisionChecker.checkContains(vertices, vertices.size, x, y)
}
Expand Down

0 comments on commit 3fdc324

Please sign in to comment.