Class: Object

me. Object

new Object()

The base class from which all melonJS objects inherit. See: https://github.com/parasyte/jay-extend
Source:
object.js, line 316

Extends

  • external:Object#

Methods

<static> extend() → {Object}

Extend a class prototype with the provided mixin descriptors. Designed as a faster replacement for John Resig's Simple Inheritance.
Parameters:
Name Type Description
mixins... Array.<Object> Each mixin is a dictionary of functions, or a previously extended class whose methods will be applied to the target class prototype.
Source:
object.js, line 153
Returns:
Type
Object
Example
var Person = me.Object.extend({
    "init" : function (isDancing) {
        this.dancing = isDancing;
    },
    "dance" : function () {
        return this.dancing;
    }
});

var Ninja = Person.extend({
    "init" : function () {
        // Call the super constructor, passing a single argument
        this._super(Person, "init", [false]);
    },
    "dance" : function () {
        // Call the overridden dance() method
        return this._super(Person, "dance");
    },
    "swingSword" : function () {
        return true;
    }
});

var Pirate = Person.extend(Ninja, {
    "init" : function () {
        // Call the super constructor, passing a single argument
        this._super(Person, "init", [true]);
    }
});

var p = new Person(true);
console.log(p.dance()); // => true

var n = new Ninja();
console.log(n.dance()); // => false
console.log(n.swingSword()); // => true

var r = new Pirate();
console.log(r.dance()); // => true
console.log(r.swingSword()); // => true

console.log(
    p instanceof Person &&
    n instanceof Ninja &&
    n instanceof Person &&
    r instanceof Pirate &&
    r instanceof Person
); // => true

console.log(r instanceof Ninja); // => false
Copyright © 2011 - 2017, Olivier Biot, Jason Oster, Aaron McLeod
Documentation generated by JSDoc 3.4.0 on 2017-02-28T11:37:41+08:00 using the DocStrap template modified by codename-.