Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Before you make a thread asking for help, read this
- Posts: 9
- Joined: Mon Jan 22, 2018 11:35 pm
Hi, I am trying to print the score to the screen but it doesn't seem to be working. I start using love2d again recently when the new update came out, and this used to work for me.
This is the whole .lua file, and the print line is right at the bottom so scroll all the way down.
Code: Select all
width = 400;
height = 488;
birdX = 50;
birdY = 220;
gravity = 0;
difficulty = "easy";
score = 0;
if (key == "space") then
if not (birdY < 25) then
gravity = -160;
gravity = gravity + (dt * 350)
birdY = birdY + (gravity * dt);
if (love.keyboard.isDown("escape")) then
function love.mousepressed(x, y, button, pressed)
if (button == 1) then
love.graphics.setColor(.14, .36, .46);
love.graphics.rectangle("fill", 0, 0, width, height);
love.graphics.print("Score: ".. score, 50, 50);
love.graphics.setColor(.87, .84, .27);
love.graphics.rectangle("fill", birdX, birdY, 30, 25);
- Party member
- Posts: 1903
- Joined: Sun Oct 18, 2015 2:58 pm
- Location: Valencia, ES
You're printing the text with the same colour as the background. Use another love.graphics.setColor right before printing the text, with the desired text colour (e.g. 1,1,1 for white).
Note also that it's probably more efficient to use love.graphics.setBackgroundColor than drawing a rectangle. Preferably, use setBackgroundColor before love.draw, otherwise you'll miss the first frame. That's because it affects the colour used by love.graphics.clear(), and the system calls love.graphics.clear() right before calling love.draw().
Users browsing this forum: Google [Bot] and 5 guests