Reading and Writing Sprite Properties


#1

I’m not understand Reading and Writing Sprite Properties section of the Map level in Lesson 7.
I’m going back through Chapter 1 looking for resources to help students who are still struggling and this information makes no sense to me and I thought I had it down pretty well!


#2

A lot of my students felt the same way about the sprite properties. It is a tough concept but essential to get mastered as It makes everything easier to create.

The = sign gets so much confusion from students in computer science. I always tell the students that it screws you up because you have to relearn what = means. Think back to when you learned the = sign in math. Now, it doesn’t mean equals anymore, it means assign to(or gets the value). Assign the value on the right hand side to the left side.

So to assign a value to a property, put the sprite along with the property on the left hand side.

//Assign the value 100 to sprite's x property
sprite.x = 100 ;

And to get a value from a property put the sprite along with the property on the right hand side.

//Get the value held in sprite's x property and assign it to the variable currentX
var currentX = sprite.x ;

Hopefully this starts to help.


#3

Thanks so much. I think that the concept of getting a value from a sprite property to use as the property for another sprite is not a part of Lesson 7 so I found the description of it in the Map Level to be confusing. It seems like a concept that needs a conditional which hasn’t been introduced yet.