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 { if let labelNode = entity.component(ofType: LabelComponent.self)?.labelNode {
scene.addChild(labelNode) scene.addChild(labelNode)
} }
if let cancelBtnNode = entity.component(ofType: CancelBtnComponent.self)?.cancelBtnNode {
scene.addChild(cancelBtnNode)
isModal = true
}
} }
func remove(_ entity: GKEntity) { func remove(_ entity: GKEntity) {
@ -90,6 +94,10 @@ class EntityManager {
modalButton.buttonNode.removeFromParent() modalButton.buttonNode.removeFromParent()
isModal = false isModal = false
} }
if let cancelBtnNode = entity.component(ofType: CancelBtnComponent.self)?.cancelBtnNode {
cancelBtnNode.removeFromParent()
isModal = false
}
entities.remove(entity) entities.remove(entity)
} }

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: { addComponent(ButtonComponent(iconName: "", text: "Senden", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 120), isEnabled: true, onButtonPress: {
self.removeModalEntities(entityManager: entityManager, gameScene: gameScene) 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)
}))
} }
} }