Skip to content

Commit

Permalink
Use SizeComponent in TouchInputSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
jobe-m committed Jul 24, 2024
1 parent c2302a8 commit f3cd9a3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ data class TweenSequenceComponent(
var x: Float = 0f, // position where entity will be spawned
var y: Float = 0f,

override var entity: Entity = Entity.NONE, // when entity is not given (=Entity.NONE) than it will be created
override var entity: Entity = Entity.NONE, // when entity is not given (= Entity.NONE) than it will be created
override var delay: Float? = null,
override var duration: Float? = 0f, // not used - 0f for immediately
@Serializable(with = EasingAsString::class) override var easing: Easing? = null // not used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ object EntityFactory {

val entityConfig = entityConfigs[name]
return if (entityConfig != null) {
val entityName = if (entity has InfoComponent) entity[InfoComponent].name else "no_name"
println("INFO: Configure entity '${baseEntity.id} ($entityName)' with '${entityConfig.name}' EntityConfig.")
entityConfig.run { world.entityConfigure(baseEntity) }
} else {
println("WARNING: Cannot invoke! EntityConfig with name '$entityConfig' not registered in EntityFactory!")
println("WARNING: Cannot invoke! EntityConfig with name '$name' not registered in EntityFactory!")
entity
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import kotlinx.serialization.*
data class DialogBoxConfig(
override val name: String,

val duration: Float,
private val duration: Float,

// Position and size
private val x: Float = 0f,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ package korlibs.korge.fleks.systems
import com.github.quillraven.fleks.*
import com.github.quillraven.fleks.World.Companion.family
import korlibs.korge.fleks.components.*
import korlibs.korge.fleks.entity.*
import korlibs.korge.fleks.utils.*
import korlibs.math.geom.*

/**
*
*
*/
class TouchInputSystem : IteratingSystem(
family {
all(TouchInputComponent, PositionComponent, TextFieldComponent)
all(TouchInputComponent, PositionComponent, SizeComponent)
},
interval = EachFrame
) {
Expand Down Expand Up @@ -47,13 +45,13 @@ class TouchInputSystem : IteratingSystem(
if (isUp) {
val inputTouchButton = entity[TouchInputComponent]
val positionComponent = entity[PositionComponent]
val textFieldComponent = entity[TextFieldComponent]
val sizeComponent = entity[SizeComponent]

val pressed = checkTouchInput(
left = positionComponent.x,
top = positionComponent.y,
right = positionComponent.x + textFieldComponent.width,
bottom = positionComponent.y + textFieldComponent.height
right = positionComponent.x + sizeComponent.width,
bottom = positionComponent.y + sizeComponent.height
)
if (pressed) {
println("TouchInputSystem: Execute '${inputTouchButton.entityConfig}' config on entity '${inputTouchButton.entity.id}'.")
Expand Down

0 comments on commit f3cd9a3

Please sign in to comment.