tween semesterön really Nicke but i havent figurer out quite how they work yet. been looking around the forum and found some code which i got inspired by. howver, it’s not working ad i expect it to do. probably because i dont fully understand tweens.
im trying to fade out a colored rect() by changing the alpha value of the fill color for the rect(). in My main i have
-- set alpha for score fx
brushAlpha = {alpha = 255}
-- colors
colors = {
color(255, 0, 0, brushAlpha.alpha), -- red
}
then in my run time code i call scoreFx() at given points and would expect the rect() to fade out but it stays solid.
function Brush:scoreFx()
tween(1, brushAlpha,{alpha = 0})
end
@coder thanks. i thought that was what i was doing with this code?
draw()
for i=1,6 do
for j=1, 6 do
palette[i][j]:draw()
fill(255,255,255)
local x = palette[i][j].pos.x
local y = palette[i][j].pos.y
--text(palette[i][j].ind, x, y)
end
end
and
function Brush:draw()
pushStyle()
fill(self.col)
rectMode(CENTER)
rect(self.pos.x, self.pos.y, self.size, self.size)
popStyle()
end
doing a print() of brushAlpha.alpha show that the alpha value nevet chages. and thats’s were im not sure what i am doing
function setup()
r={x=WIDTH/2,y=HEIGHT/2,alpha=255}
tween(5,r,{alpha=0},{easing=tween.easing.linear,loop=tween.loop.pingpong})
end
function draw()
background(0)
fill(255,0,0,r.alpha)
rect(r.x,r.y,200,200)
end