V
V
voproser456542022-03-07 12:18:10
Lua
voproser45654, 2022-03-07 12:18:10

How to change parameters in love2d?

There is a code for love2d

function button(mode, x1, y1, width, height, r1, g1, b1)
    color = {r1, g1, b1}
    love.graphics.setColor(color)
    love.graphics.rectangle(mode, x1, y1, width, height)
    r1 = r1 + .1
end

It is called in the draw function, but the color does not change, what's the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2022-03-07
@dollar

Why something does not work in the program, you need to find out by debugging .
For Lua, this is a function. print()
The problem is localized like this:

  1. We are trying to simply call love.graphics.rectangle()with known parameters to make sure that the function basically works with these parameters and that this is not the case.
  2. We insert print(mode, x1, y1, width, height)to make sure that a) the program, in principle, has reached this point, b) the parameters are exactly what you need.
  3. Further, depending on what we see, we draw conclusions. Yeah, if it's like this, then let's put it print()in another place to check it too.
  4. Etc.

Each next error search step depends on the previous one. And here, any responder, not having access to all the code and the ability to run and check, will be forced to play a guessing game. Or maybe this, or maybe that, a million reasons. Maybe a bug in the program, or maybe even in some OS driver or the wrong version of some application. And even if the error is in the program, there are a million places where it can be.
Therefore, the programmer who writes the code should deal directly with debugging his program.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question