Sprite Properties
-
In case people hadn't realised sprites have properties. These can be accessed directly without using the getter and setter methods to read/write values.
So for instance you can do sprite.rotation = angle rather than setSpriteRotation(sprite, angle)
The full list is shown below:
x horizontal position y vertical position rotation rotation angle xscale horizontal scale yscale vertical scale r red colour value g green colour value b blue colour value a alpha colour value xorigin horizontal origin yorigin vertical origin depth display depth visible visibility x_speed change in x per update y_speed change in y per update rotation_speed change in rotation per update xscale_speed change in xscale per update yscale_speed change in yscale per update r_speed change in r per update g_speed change in g per update b_speed change in b per update a_speed change in a per update anim_speed animation speed anim_frame animation frame show_collision_shape show or hide collision shape
It is also possible to add you own properties. So for instance you can do:
sprite.hitpoints = 100
-
This isn't documented and thank you so much for putting that here @pianofire
I'll make sure to add this information to the sprite tutorial, or perhaps do a separate document for this.
-
This is gold! thank you.
-
Must know more how do I use this information?
-
It just means that instead of having to do
setSpriteLocation(sprite, x, y)
You can instead just say:
sprite.x = nnn
Which as you can see means you don't need to specify both if only one has changed.
That's one example. @pianofire has given the fuill list of properties. The keen-eyed will also notice that there is at least one that does not have an equivalent "setSprite" variant function.
I'll leave you to work out which one(s) as a learning exercise
-
bonus prizes for discovering which values can only be set or read by setsprite() and getsprite() functions and not via their sprite.name property 😊