A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Color Changing Game

  1. #1

    Color Changing Game

    Im working on a project where the objects the player picks up change the color of the world around him. So picking up a red object makes everything appear in greyscale except for other red objects. It needs to work for a dozen or so different colors, and Ive hit a roadblock. I have been using getPixel and setPixel to change the large image's colors that way

    Code:
    if (backdrop.getPixel(h,w)==0x979F83) {canvas.setPixel(h,w,0x9A9A9A}
    which worked fine in a prototype but in the actual game the image is way waaay to big for that.

    What other methods could I implement for a similar effect of selectively greyscaling out large swaths of a bitmap or only copying over selective colors???

    btw Im using copyPixel because there are a few large bitmaps with a variety of depths and vectored images were producing too much lag

  2. #2
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    Check out the ColorTransform filter. There you can specify multipliers for each colour channel.
    If that doesn't work out, I'd say just have the different coloured objects in different BitmapData's that you fade in when you need the objects hi-lighted.

    P.
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  3. #3
    Ive messed with the colorTransform a bit but not been able to quite get the effect Im looking for.

    Otherwise I would have to draw out a bitmap for each of the dozen or so colors, essentially multiplying the total art in the project 12 times over. I can't explode the file size like that, isn't there some way to use a single bitmap and saturate out certain color ranges? or maybe use two bitmaps, one color and one grey, and only copyPixel certain colors over from the second? maybe make the colored bitmap transparent in parts?

  4. #4
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    maybe look at bitmapData.paletteMap
    lather yourself up with soap - soap arcade

  5. #5
    paletteMap might work- havnt gotten it quite right yet but I'll try it out. Ive also found out about threshold, before I dive into figuring it out I thought I should ask would that be applicable here?

  6. #6
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    threshold could work, but it could possibly run slow on large bitmaps. Something like this might work: (set all colors that don't equal red to grey)

    target.threshold(source, target.rect, new Point(), "!=", 0xFFFF0000, 0xFF7F7F7F, 0xFF, false);

    I'd play around with the last parameter to copy pixels from the source.
    lather yourself up with soap - soap arcade

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center