Adding Abbrechen Button to ModalAttack

This commit is contained in:
Chauntalle Schüle 2020-05-15 13:29:03 +02:00
parent 5d98027d8a
commit 8b840b5089
2 changed files with 14 additions and 3 deletions

View File

@ -68,6 +68,10 @@ class EntityManager {
if let labelNode = entity.component(ofType: LabelComponent.self)?.labelNode {
scene.addChild(labelNode)
}
if let cancelBtnNode = entity.component(ofType: CancelBtnComponent.self)?.cancelBtnNode {
scene.addChild(cancelBtnNode)
isModal = true
}
}
func remove(_ entity: GKEntity) {
@ -90,6 +94,10 @@ class EntityManager {
modalButton.buttonNode.removeFromParent()
isModal = false
}
if let cancelBtnNode = entity.component(ofType: CancelBtnComponent.self)?.cancelBtnNode {
cancelBtnNode.removeFromParent()
isModal = false
}
entities.remove(entity)
}
@ -100,9 +108,9 @@ class EntityManager {
if base.changeOwnership {
base.addComponent(TeamComponent(
team: (entities[0] as! Base).component(ofType: TeamComponent.self)!.team,
player: (entities[0] as! Base).component(ofType: TeamComponent.self)!.player,
position: (base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position)!
team: (entities[0] as! Base).component(ofType: TeamComponent.self)!.team,
player: (entities[0] as! Base).component(ofType: TeamComponent.self)!.player,
position: (base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position)!
)
)
base.changeOwnership = false

View File

@ -30,6 +30,9 @@ class Modal: GKEntity{
addComponent(ButtonComponent(iconName: "", text: "Senden", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 120), isEnabled: true, onButtonPress: {
self.removeModalEntities(entityManager: entityManager, gameScene: gameScene)
}))
addComponent(CancelBtnComponent(iconName: "", text: "", position: CGPoint(x: anchorPoint.x + 160, y: anchorPoint.y + 140), isEnabled: true, onButtonPress: {
self.removeModalEntities(entityManager: entityManager, gameScene: gameScene)
}))
}
}