Skip to content

Instantly share code, notes, and snippets.

@rvanzon
Created February 23, 2015 06:51
Show Gist options
  • Select an option

  • Save rvanzon/044f7d0dbbc7bdf04ea2 to your computer and use it in GitHub Desktop.

Select an option

Save rvanzon/044f7d0dbbc7bdf04ea2 to your computer and use it in GitHub Desktop.
MelonJS ES 6 concept
class Player extends meEntity {
constructor(x, y, settings) {
super(x, y, settings);
}
update(dt) {
super.update(dt);
}
onCollision(a, b) {
return false;
}
}
// Transpiled to:
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var Player = (function (meEntity) {
function Player(x, y, settings) {
_classCallCheck(this, Player);
_get(Object.getPrototypeOf(Player.prototype), "constructor", this).call(this, x, y, settings);
}
_inherits(Player, meEntity);
_prototypeProperties(Player, null, {
update: {
value: function update(dt) {
_get(Object.getPrototypeOf(Player.prototype), "update", this).call(this, dt);
},
writable: true,
configurable: true
},
onCollision: {
value: function onCollision(a, b) {
return false;
},
writable: true,
configurable: true
}
});
return Player;
})(meEntity);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment