Skip to content

Commit

Permalink
Introduce size property
Browse files Browse the repository at this point in the history
  • Loading branch information
Reco1I committed Dec 28, 2024
1 parent f991d58 commit 6c1a2af
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/com/reco1l/andengine/Entities.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.reco1l.framework.math.Vec4
import org.anddev.andengine.entity.IEntity
import org.anddev.andengine.entity.scene.CameraScene
import org.anddev.andengine.entity.shape.IShape
import kotlin.math.max


fun IEntity?.getPadding() = when (this) {
Expand All @@ -26,6 +27,20 @@ fun IEntity?.getPaddedHeight() = when (this) {
}


/**
* The size of the entity.
*
* When using the getter this will return the maximum value between the width and height or the same.
* When using the setter this will set the width and height to the same value.
*/
var ExtendedEntity.size
get() = max(width, height)
set(value) {
width = value
height = value
}


/**
* The total offset applied to the X axis.
*/
Expand Down

0 comments on commit 6c1a2af

Please sign in to comment.