Sprite.count get 1 after destroy sprite

  • Problem Description

    ____ System got 1 of [Sprite.count] after Destroy the [Sprite] ____

    Attach a Capx

    ____ https://www.dropbox.com/s/d6ib1hg1zb5uu ... .capx?dl=0 ____

    Description of Capx

    ____ Concise description of what this CapX does ____

    Steps to Reproduce Bug

    • Create a Sprite object on layout
    • Create a Text object on layout
    • Create a On start of layout event
    • Create Destroy action to the sprite
    • Create an Set text action with value of Sprite.count
    • Run Layout

    Observed Result

    ____ Value is 1 ____

    Expected Result

    ____ Value should be 0 ____

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Internet Explorer: (YES/NO)

    Operating System and Service Pack

    ____ Win 7 SP1 ____

    Construct 2 Version ID

    ____ Release 252 ____

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I had this problem too, but I think the 'on destroyed' trigger occurs before the destruction is processed, not after. It's helpful, because you can use the destroyed sprites's variables and position to do things like place an explosion, but yeah it does mean the sprite still is counted by the count.

    I just change my checks to if sprite.count = 1. Or maybe you can could use a separate event "if sprite.count = 0"?

  • This is by design. Objects aren't really destroyed until the end of the next top-level event. This is an important feature so events like "Destroy Sprite, create explosion at Sprite" do what you expect (since there is still a sprite to create an explosion at in the subsequent action). Closing as not a bug.

  • Noted with thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)