Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Root._player doesn't exist. Try accessing it via the engine class.</p> <p>So, if an engine object exists at the root and is called _engine, you can access _player like the following:</p> <pre><code>var plyr:player = _engine._player; </code></pre> <p>EDIT: The collision class doesn't "know" about the engine class; they both exist separately from one another so there's no way to get them to communicate with each other without doing something different. One method, mentioned in comments, is to make the _player property static in engine. So</p> <pre><code>public static var _player:player; </code></pre> <p>Another way would be to make the engine class a singleton (as mentioned in another answer). </p> <p>Another way would be to pass the instance of the engine class to the collision class; that way the collision class is able to "see" the instance variables (properties) available in engine. To do that, you could do something like:</p> <pre><code>// do this inside the engine constructor _collision = new collision(); _collision._engine = this; </code></pre> <p>(Collision should have a var called _engine:engine, to do this, of course.)</p> <p>You may want to step back from your design and think about how each part should interact with one another. It's possible that there's a different way to do things which will make each object better able to communicate with one another (or, by separating concerns, take responsibility for what each class is supposed to do <em>without</em> directly interacting with other classes).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload