Handling touches alpha question

I am trying to walk through some of the simpler examples first to get a basic understanding of how things work using lua, I don’t do much programming in graphics at work, usually automation of processes (spreadsheets, text files, outlook, word, excel, etc…), however i have the basics down and am lost on how the alpha apparently changes over a period of time when using this example.

I see all fills set with 255 as the alpha and nothing saying to decrease the alpha during or after the drag starts. Normally you would have to track those ellipses changing each ones alpha until it goes to 0 and drop off the array or dictionary or whatever your container is.

How is that being accomplished in this short little program? I don’t see any change in alphas.


You seem to be refering to a program, but you dont indicate which program? Difficult to help you then…

In the examples, the example program called “handling touches” has a red swirl graphic.

function setup()
    print("Touch and drag on the screen")

function draw()
    fill(0, 0, 0, 10)


    if CurrentTouch.state == BEGAN then
        fill(16, 178, 197, 255)
    elseif CurrentTouch.state == MOVING then
        fill(255, 0, 0, 255)
    elseif CurrentTouch.state == ENDED then
        fill(210, 218, 16, 255)

    ellipse(CurrentTouch.x, CurrentTouch.y, 100,100)

Use three (3) ~ at the top and bottom of your code to format it. I fixed it for you.



means the previous content on the screen, well it actually means that the previous frame gets copied to the current frame

but then


makes the ‘background’ (well this is an imitated background because it uses a rectangle, cause using


erases the screen

so the rectangle makes it so that what’s on the screen, gets reduced alpha by 10 ‘each frame’ so that reduced graphics get drawn onto the screen and reduced again…

Well this isn’t the best explaination but hey, I gotta try :wink:

@JCKent - normally, the draw function starts with a background command that covers over the previous drawings with a given colour, so that each frame starts from nothing.

In this case, the previous drawing is left on the screen, and a very faint tint is applied to make it darker, frame by frame, giving a fade out effect.

It’s an unusual approach so I’m not surprised it’s confusing.

By the way, my background is also Excel and VBA (with lots of automation experience!) and I started with little or no graphics experience earlier this year, but I’m loving Codea. It takes some getting used to, but the language is very like VBA, and the tables are amazing.

Briarfox- thanks, didn’t know that format trick.

Stevon8tr & ignatz- thank you both very much. So does that mean that every circle is left on the screen in memory, never cleared? Just has 25 alpha 10 rectangles on top of them when they disappear?

Thanks all of you, very fast and, well …helpful, help,