Hello,
I am trying to show an AnimatedSprite as an Explosion/Death Animation via the following Code, the Animation is now shown properly, because I don’t call enemyAnim.stop() directly after setting the explosion AnimatedSpriteVPlay… is there any possibility to react to finishing the Animation and finally destroy the entity?
EntityBase {
id: shipEntity
entityType: "ship"
variationType: "enemy"
width: 32
height: 32
Rectangle {
color:"transparent"
anchors.fill: parent
Image {
id: shipImage
smooth: false
source: "../../assets/img/enemy.png"
anchors.fill: parent
}
AnimatedSpriteVPlay {
id: explosion
width: 32
height: 32
loops: 1
visible: false
frameWidth: 16
frameHeight: 16
frameCount: 4
startFrameColumn: 1
frameRate: 20
source: "../../assets/img/sprites/explosion.png"
}
}
BoxCollider {
categories: Box.Category2
// the BoxCollider will not be affected by gravity or other applied physics forces
collisionTestingOnlyMode: true
collidesWith: Box.Category1
// make the same size as the Image
anchors.fill: shipEntity
fixture.onBeginContact: {
shipImage.visible=false
explosion.visible=true
explosion.restart()
}
}
function startAnimation(to) {
enemyAnim.to=to
enemyAnim.start()
}
// moves the entity to y position 0 within 1 second
NumberAnimation on y {
id:enemyAnim
duration: 4000
running: false
onStopped: {
shipEntity.removeEntity()
}
}
Thanks in Advance.
-
This topic was modified 8 years, 4 months ago by
Deathdragon.