Tuesday, June 17, 2014

Simple Platformer Day 09

Static: everything used by a static function needs to also be static.
(still not super clear on what can and cannot be static, research reading later)

Crazy hackery to refer to an otherwise non-static class:

Protected static  |class| |instance name| = null;

void Awake() {
|instance name| = this;
}

Notes:
 protected = just means "members of flowerScript can see this, everyone else go away"
static = "this variable is shared by every member of this class, and you don't need to be a member to use it"
flowerScript = this is the type of our variable
m_instance = the name I picked out
"type" is like int, string, etc.
Any class you make is a type too.
null = I don't have an initial value for this, so I'm leaving it empty for now
Singleton: a clean way for static objects to be able to accept and use editor links.

  • Made a killfloor.
  • Restart function currently cannot reposition player due to  "NullReferenceException: Object reference not set to an instance of an object"

  • Need to figure out a way for restart function to wipe out all remaining flowers on screen.
  • Need to get a restart button to display on player death.

No comments:

Post a Comment