azerion / phaser-input

Adds input boxes to Phaser like CanvasInput, but also works for WebGL and Mobile, made for Phaser only.
MIT License
201 stars 64 forks source link

Text box still shows up white after changing properties #71

Open ThePandaJam opened 5 years ago

ThePandaJam commented 5 years ago

Hi! I'm trying to make a transparent text input box (or one with the same colour as the background image) in my game and I've been changing the properties to suit my needs, but the box still shows up white. Can't really find much help elsewhere online...

Here's my code:

var nameInput = game.add.inputField(600, 510, {
            font: "32px 'Press Start 2P'",
            fill: "#ffffff",
            align: "center",
                        borderWidth: 0,
                        borderColor: '#ffffff',
//changing border in the text configuration worked, so trying to change bgColour here
            background: "#0BE783",
        });
                //changing colour to blend in with background
        nameInput.backgroundColor = "#0BE783";
        nameInput.fillAlpha = 0;
        nameInput.width = 300;
        nameInput.height = 34;
        nameInput.cursorColor = '#ffffff';

I'm using Phaser v2.3.0 @AleBles

ThePandaJam commented 5 years ago

image

MajorKuprich commented 5 years ago

I have a similar problem regarding the change in the width of the input. Whether the width is changed correctly in ur project? I mean this line: nameInput.width = 300;

ThePandaJam commented 5 years ago

I found a fix for this issue. Just needed to add more attributes

var nameInput = game.add.inputField(500, 498, {
    font: "30px 'Press Start 2P'",
    fill: '#ffffff',
    fillAlpha: 0,
    fontWeight: 'bold',
    width: 400,
    max: 20,
    padding: 2,
    borderWidth: 1,
    borderColor: '#000',
    borderRadius: 6,
    placeHolder: 'Anonymous',
    textAlign: 'left',
    zoom: true,
    cursorColor : '#ffffff'
    });
nameInput.startFocus();

The last line is pretty important by the way.

ThePandaJam commented 5 years ago

@MajorKuprich That width change worked fine, the text there would go outside the white box, as per the width I set. It's just the white box that wouldn't go away no matter what i did to the attributes regarding background colour. I fixed it now, take a look at the code above. :)