Change the color of multiple of the same object

0 favourites
  • 9 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • All of the enemies are supposed to flash red and blue, as shown in the picture

    However, only one of them seems to do it, even if I use the For Each Obj event.

    Any help?

  • You are probably picking one enemy in this event. Try adding "System pick all". For example:

    Bullet on collision with Enemy
    	System pick all Enemy 
    		Enemy Flash...
    

    If this doesn't help, please post your code.

  • sorry. The "bullets" are actually particles, I should have been more clear.

    https://drive.google.com/open?id=1N1OQZrYKdTRYi2wE2jjTshcpuiQJyT7B

  • What event should I look at? Please explain the problem.

    Your game doesn't work for me, there is nothing but black screen. And it shows this error in browser console:

    Uncaught (in promise) TypeError: Cannot read property '_GetLastCachedZIndex' of null

  • events 28 - 34, as well as 44.

    All of the enemies are supposed to flash red and blue slowly for 2 seconds, then quickly for another 2 seconds, then loop (no matter what)

    as for the game being a black screen, I am just as clueless. It doesn't work on my end either

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ok here is working cp3

    https://drive.google.com/open?id=1N1OQZrYKdTRYi2wE2jjTshcpuiQJyT7B

    now it seems that most of the enemies are flashing, but only slowly or never. I would like them to flash slowly and quickly.

  • Should each enemy flash separately from others? Or all enemies flash at once, synchronized?

    If each enemy has its own flash cycle, then the easiest solution would be creating a single animation RED-BLUE-RED-BLUE-red-blue-red-blue-red-blue-red-blue, and loop it. Set speed=2 for the first four frames and speed=4 for remaining frames. No events will be required.

    To get the current color use AnimationFrame%2 expression, if result=0, it's red, if result=1, it's blue.

    Or you can make an animation with two frames RED-BLUE, looping, and run a timer for 2 seconds on each enemy. On timer change speed of the animation (make it faster or slower).

    .

    If all enemies should flash simultaneously (synchronized), then you can do this with global variables. Add a global variable CurrentColor (may be "red" or "blue"), set animation to this variable for all enemies, and also when a new enemy is created. Every 0.5 or 0.25 seconds toggle the value. Every 2 seconds toggle the speed.

  • Thank you that makes a lot more sense.

    I do want all of the enemies to flash separately.

    Also, I'm assuming % is mod?

  • Yes, % is modulo operator.

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