Jump to content

Manipulate visual object's alpha without redrawing it?


spinnerbox
 Share

Recommended Posts

I was wondering is there a Phaser visual subtype on which I can manipulate its alpha/transparency without redrawing it?

Phaser.Graphics is ok but I need to redraw it and currently I am lost in my own code :D

I have the graphics already drawn, it would be a lot easier to just change its alpha value.

Sprite/Image does not seem to have alpha value.

Is there some plug-in or perhaps some known hack?

Link to comment
Share on other sites

Yes, the whole thing. Also it would be good if i can change its size dynamically.

It is just an indicator rectangle. It shows that you can add part or not. It should have green colour and alpha 0.5 if adding part functionality is enabled and red with alpha 0.5 if adding part functionality is disabled.

 

Link to comment
Share on other sites

@lumoludo This answers my question completely.

In addition,

mySprite.width = 30; 
mySprite.height = 10;

are also editable. I made png image 10x10 all white just to have image key in the cache.

var slotRect = gameObject.add.sprite(rect.x,
                            rect.y + ((rect.height / fcdo.maxNumOfShelves) * i),
                            'SHELVE_SLOT');

slotRect.width = rect.width;
slotRect.height = fcdo.shelveShiftFactor;
slotRect.alpha = 0.0;
slotRect.tint = rect.fillColor;

This code works perfectly.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...