How do I Create Objects based on Variable?

0 favourites
  • 4 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I am not sure if this is even the best way to describe what I am trying to do but here we go. I have a Energy sprite that has two animations. 1 is grey(empty) and the other is blue(player health) I have a global variable player_health = 5

    When it is 5 I want to show 5 blue energy sprites in a row on screen

    4 would display 4 blue and 1 grey

    3 would display 3 blue and 2 grey

    And so on

    I have created other arrays for other sprite changes in the game but there is only one instance of those particular sprites on the screen at a time but this I need them laid out differently and i think I am approaching this wrong.

    Any ideas?

  • I don't quite understand why you need 5 sprites for one energy bar. Why don't you use just one sprite with 5 frames in it? First frame is 5 blue blocks, second frame is 4 blue+1 grey etc.

    Another option is to use a static sprite with 5 grey blocks, and tiled background above it with blue blocks, which you can resize to change the number of blue blocks.

  • oh and then reference frameX based on player_health variable value

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • that worked...for my hp, enemy hp and timer.

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