OK
I found in this forum examples about using classes and manipulating them.
Here is an example I really do not understand from the programmer point of view. Probably this is due to my lack of gaming programming experience.
So could somebody help me by explaining what can be the use of the following manipulation of code?
I know about subclassing and extending but this example does not help me at all to know how to code clean instructions?
Consider Writing Mixins and Helpers Instead of Subclassing
It’s very easy to write classes that know about one another and cooperate, and this is probably a better and more
maintainable way of specializing objects in Unity than subclassing.
E.g.
/* Foo.js /
var bar : Bar;
function Start(){
bar = gameObject.GetComponent(Bar);
}
function doEet(){
// do my own thing
if( bar ){
Head First into Unity with JavaScript - Unify Community Wiki http://www.unifycommunity.com/wiki/index.php?title=Head_First_int…
3 sur 10 23/07/2010 15:49
bar.doEet();
}
}
/ Bar.js */
function doEet(){
// do something special
}
First there is that ambiguity between ‘bar and Bar’
second I don’t see how doEet becomes a Bar class or function and why would I do that?
Thanks in advance for shedding bright lights on this..
Yves