The problem I seem to be having is that the text box is not dissapearing smoothly but suddenly. I was wondering if I should use a timer to smoothen the transition from drawn to not drawn.
The love file is included.
Press k to draw the box and q to undraw it.
Also you can move the little player box with the arrow keys, although he won't move with the textbox around which is intentional.'
(SOLVED) Trouble with Drawing and Not Drawing an object
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Trouble with Drawing and Not Drawing an object
Smoothing definitely looks better. Here is a quick solution for your problem.
If you replace the number 2550 in these lines you can make the transition faster or slower.
I extended the textbox-drawing function so that it takes an alpha-value as parameter. Then, when "k" is pressed, each frame the alpha value is changed until it reaches 255. If the textbox is not running, then the alpha value is lowered until zero. The math.min and math.max make sure that the alpha always stays between 0 and 255.
Code: Select all
if msg_box.running then
alpha = math.min(alpha + 2550*dt,255)
else
alpha = math.max(alpha - 2550*dt,0)
end
Check out my blog on gamedev
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests