انتقل للمحتوى
Robo EgyptRobo Egypt
☰ Course contents

The game canvas: paint with your finger

Section 9: GamesLesson 9.1 · ⏱ 10 min
When the finger drags on the canvas: draw a small circle where it touches, in the colour of the variable color
When the finger drags on the canvas: draw a small circle where it touches, in the colour of the variable color
We drew in red, then tapped 🔵 and drew a blue line
We drew in red, then tapped 🔵 and drew a blue line
  • A canvas is a space you draw on and put sprites in.
  • touch x and touch y are where the finger is on the canvas.
  • The 🧽 button clears the whole drawing.
  1. Add a green button.
  2. Make a button that makes the brush bigger (a variable for the size).

📌 Another example: a brush with three sizes

Buttons change the brush size, and we draw with the finger.

The design
The design
The blocks
The blocks
In the lab: a thin line and a thick line
In the lab: a thin line and a thick line
✍️ Practise
Make the example yourself: put the parts in “🎨 Design”, then the blocks, and tap ▶ Run.
✍️ Practise here in the lessonor open the lab in a new page ↗

🎯 Challenge yourself

Easy

Draw in green.

👀 Show the solution
The design
The design
The blocks
The blocks
In the lab
In the lab

Result: a green line.

Medium

A tap on the canvas draws a big circle there.

👀 Show the solution
The design
The design
The blocks
The blocks
In the lab
In the lab

Result: a red circle.

Hard

A “Clear” button clears the canvas.

👀 Show the solution
The design
The design
The blocks
The blocks
In the lab
In the lab

Result: the canvas is empty.

Finished the lesson? Mark it so your progress counts.