1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 [GML] How to make my character flash different colors

Discussion in 'Programming' started by evolsuperx, Jun 26, 2016.

  1. evolsuperx

    evolsuperx Guest

    I am making a crossover game and I am wondering how can I make my character flash similar to how zero flashes through different color while he is charging his beam up. http://puu.sh/pG4a1/69585ce492.gif < you may can't see it good because of the gif frame rate.
     
  2. bojack29

    bojack29 Member

    Joined:
    Jun 21, 2016
    Posts:
    407
    Definitely a shader would work wonders here.

    Basically you grey scale the areas of a sprite that are to be treated with color. Then you include a uniform into the shader that will look for all pixels within the sprite that are r == b == g. (All the reds, blues and greens match in value - meaning it is white, gray or black).

    Then you treat those colors with whatever color it was that you used in the uniform.

    Edit: Or what atx said about making the images yourself ^^^^. That would work too.
     
    Rivo likes this.
  3. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,460
    Pixelated_Pope made a palette-swap shader back on the old forums that is pretty good, check that out. It should be in the Shaders sub-directory, pretty high up in the list since a lot of people commented on it all the time.

    ...or never mind, I'll go get it for you: http://gmc.yoyogames.com/index.php?showtopic=587773
     
  4. Snail Man

    Snail Man Member

    Joined:
    Jun 20, 2016
    Posts:
    282
    Seems like for this simple of a thing, just making an alternate sprite to flicker back and forth is the best approach. Unless you need to do it along large parts of the screen, a shader seems like overkill
     
  5. Roa

    Roa Member

    Joined:
    Jun 20, 2016
    Posts:
    549
    If you want him to flash during any animation, you would have to make separate sprite sheets of every color of flash and have those ready on texture pages. Also have to go through the manual labor of recoloring all those animations.

    OR

    Could just call a shader before draw :p
    Its not overkill.
     
  6. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,460
    Shaders aren't that hard to use once you get into it, really. I've started using shaders for enemy hurtflashes lately, and it's just two more lines of code compared to my previous approach. I find it a lot harder to MAKE shaders than using them x3
    ...and even so, you don't really need to make shaders either since there's so many free ones available on the Marketplace.

    (And that's probably because GM doesn't have help for them, and the official documentation is a lot more spread out and hard to read)
     
  7. evolsuperx

    evolsuperx Guest

    Well, I am going to use image_blend. Thanks for the suggestion, ladies and gentle. I gotta look into shaders one day, aswell.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice