How do I select a sprite by reference to it's name ?

0 favourites
  • 3 posts
From the Asset Store
It's here!
$4.95 USD
Creepy and nasty horror track. It's terrifying from the beginning till the end. Goosebumps guaranteed
  • I have a set of sprites called enemy1, enemy2, enemy3 and enemy4 - I also have a global called "whichenemy" and it will contain an integer between 1 and 4 - How do I select the sprite associated with the global so as I can then perform an action on that sprite - IE: Pseudocode would be :

    select "enemy" + str(whichenemy) {

    this.doaction

    }

    Any help much appreciated 🙂

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't think you can do it by name you'll need to pick the object. What's the problem you are having where you can't just pick enemy1 for example?

  • It is possible if you combine all sprites to a family. Then you can use this condition to pick family member by name:

    System Pick EnemiesFamily By Evaluate: EnemiesFamily.objectTypeName="enemy"&number

    But if you are going to use a family, I suggest defining an instance variable "EnemyType" on the family to make picking easier.

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