[AndEngineLimbo] Make your sprite gray(ish) in realtime!

  ... the case you feel the need for a new feature or want to submit one.

[AndEngineLimbo] Make your sprite gray(ish) in realtime!

Postby nazgee » Thu May 30, 2013 1:52 am

What is AndEngineLimbo?
Have a look at first post here: features/positioner-t11930.html

Get Limbo from here: https://github.com/nazgee/AndEngineLimbo

SaturetableUniformColorSprite - Sprite with changeable Saturation
Ever wanted to make your sprite grayscale in real-time? Now you can!

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. this.mIcon = new SaturateableUniformColorSprite(0, 0, pTextureRegion, pVBOM);
  2. // 1.0 is full color
  3. // 0.0 is grayscale
  4. this.mIcon.setSaturation(0f);
  5.  
Parsed in 0.013 seconds, using GeSHi 1.0.8.4


But remember to register shader that this class uses (otherwise it'll have isssues when resuming game):
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2. public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) {
  3. ...
  4. this.getShaderProgramManager().loadShaderProgram(PositionTextureCoordinatesUniformColorSaturationShaderProgram.getInstance());
  5. }
Parsed in 0.010 seconds, using GeSHi 1.0.8.4


This is how it looks like in action (srollbar on left, two items are grayed out as inactive):
gray.png
gray.png (164.04 KiB) Viewed 1313 times


NOTE: this IS SLOWER than regular Sprite (fragment shader is a little bit more complicated, so use it with care!
Last edited by nazgee on Thu May 30, 2013 12:55 pm, edited 2 times in total.
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 527
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Re: [AndEngineLimbo] Make your sprite gray(ish) in realtime!

Postby yhyang » Thu May 30, 2013 9:31 am

Thanks, this is useful, don't need to create extra graphics for disable purpose any more.
yhyang
 
Posts: 115
Joined: Thu Nov 22, 2012 9:46 am
Location: Taiwan

Re: [AndEngineLimbo] Make your sprite gray(ish) in realtime!

Postby nazgee » Thu May 30, 2013 12:56 pm

Just remember that it is a little bit slower than regular Sprite. I forgot to show how to register shader that this class uses- updated first post with this info.
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 527
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Re: [AndEngineLimbo] Make your sprite gray(ish) in realtime!

Postby Niffy » Fri May 31, 2013 8:58 pm

Nice that will come in handy at some point. Just cloned it to my computer :D
Niffy
 
Posts: 284
Joined: Sat Sep 17, 2011 8:39 pm


Return to Features

Who is online

Users browsing this forum: No registered users and 5 guests