Lesson 6: Getting Properties
45 minutes
Overview
This lesson introduces students to the getProperty
block, which allows them to access the properties of different elements with code. Students first practice using the block to determine what the user has input in various user interface elements. Students later use getProperty
and setProperty
together with the counter pattern to make elements move across the screen. A new screen element, the slider, and a new event trigger, onChange
, are also introduced.
Purpose
So far, students have only used the button press event to gather information from the App Lab screen. Using getProperty
opens the students to gathering a wide range of information from the user. Getting properties also allows students to create programs that don't rely on knowing an element's properties when the code is written, so their programs can be more dynamic and interactive. These features will be important as students move toward making an interactive game in the next few lessons.
Assessment Opportunities
-
Use getters to access the properties of elements in a system
Code Studio: see rubric on bubble 5
Agenda
Objectives
Students will be able to:
- Use getters to access the properties of elements in a system
Links
Heads Up! Please make a copy of any documents you plan to share with students.
For the teachers
- CSD Unit 6 - Physical Computing - Slides
- Taking Input with getProperty - Resource
Introduced Code
Teaching Guide
Warm Up (5 minutes)
Review: Ask students to think of the different types of information that they were able to get from the board in the last lesson (e.g. button presses, toggle state, etc.)
Remarks
So far we've seen lots of ways that we can get information from our Circuit Playground. Today we're going to look at more ways that we can get information from the screen of our app.
Activity (35 minutes)
Send students to Code Studio.
Level 5 You can use this level as a formative assessment for students. Click inside the level to view a rubric and leave feedback to your students
Wrap Up (5 minutes)
Journal Prompt: So far, you've seen several different types of input, some from the screen, and some from the circuit playground. Choose one type of input and answer the following questions about it.
For this prompt, you can "jigsaw" the answers by assigning different students or different groups each a type of input and answering questions on each type. The different answers can then be combined for a class reference on input types.
- What code do you need to get information from this input?
- What's one example of when you would want to use this input?
- What's an example of when you wouldn't want to use this input?
This work is available under a Creative Commons License (CC BY-NC-SA 4.0).
If you are interested in licensing Code.org materials for commercial purposes contact us.