spinnerbox Posted September 6, 2016 Share Posted September 6, 2016 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 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 More sharing options...
lumoludo Posted September 6, 2016 Share Posted September 6, 2016 Sprites and images should have an alpha value. You just want to change the transparency of the entire thing and not individual pixels, right? myImage.alpha = 0.5; Should do the trick. Keep in mind that alpha values are 0-1 and not 0-255. spinnerbox 1 Link to comment Share on other sites More sharing options...
spinnerbox Posted September 6, 2016 Author Share Posted September 6, 2016 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 More sharing options...
lumoludo Posted September 6, 2016 Share Posted September 6, 2016 To change the size of an image/sprite, you can use the scale property: mySprite.scale.x = 2.3; mySprite.scale.y = 2.3; To change the color of the image/sprite, you can use the tint property: myImage.tint = 0xff0000; //Red myImage.tint = 0x00ff00; //Green spinnerbox 1 Link to comment Share on other sites More sharing options...
spinnerbox Posted September 7, 2016 Author Share Posted September 7, 2016 @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 More sharing options...
Recommended Posts