Skip to content

Commit

Permalink
[#1008] me.CollectableEntity and me.LevelEntity are now deprecated an…
Browse files Browse the repository at this point in the history
…d replaced respectively by more generic me.Collectable and me.Trigger objects that do not extend me.Entity anymore

only remaining item now is to properly deprecate me.Entity. but for this version it's only gonna be a warning with no built-in replacement like here.
  • Loading branch information
obiot committed Sep 9, 2021
1 parent f34593b commit 493d9e0
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 144 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
- Core : the "legacy" es5 umd bundle is now automatically transpiled (from ES6 to ES5) using rollup and bubble
- Core : internal rewrite on object bound implementation, with all Renderable now fully using/relying on the me.Bounds object introduced in last version
- Container : Containers defines an additional `enableChildBoundsUpdate` flag to enable full bounds update, including child bounds (disabled by default)
- Entity : me.CollectableEntity is now deprecated and replaced by a more generic `me.Collectable` base object that do not extend me.Entity anymore
- Entity : me.LevelEntity is now deprecated and replaced by a more generic `me.Trigger` objects that do not extend me.Entity anymore
- Renderer : WebGL2 is now the default mode when using the WebGL renderer (use `preferWebGL1 = true` calling me.video.init if you need to force WebGL1)
- Tiled : add TMX `tintcolor` parsing for tile and object layers
- Stage : `me.Stage` constructor now accept new argument properties to specify the `onResetEvent` and `onDestroyEvent` functions
- Stage : fix a crash with legacy API when using the deprecated me.ScreenObject object
- TMX : fix crash when trying to add collisionType to text nodes (thanks @framp)
- TMX : fix a regression with the Tile Layer preRender feature
- TMX : fix tile properties import for the new Tiled JSON format (thanks @3ck0o)
Expand Down
24 changes: 0 additions & 24 deletions src/entity/collectable_entity.js

This file was deleted.

111 changes: 0 additions & 111 deletions src/entity/level_entity.js

This file was deleted.

16 changes: 8 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import ColorLayer from "./renderable/colorlayer.js";
import ImageLayer from "./renderable/imagelayer.js";
import Sprite from "./renderable/sprite.js";
import GUI_Object from "./renderable/GUI.js";
import Collectable from "./renderable/collectable.js";
import Trigger from "./renderable/trigger.js";
import TMXRenderer from "./level/tiled/renderer/TMXRenderer.js";
import TMXOrthogonalRenderer from "./level/tiled/renderer/TMXOrthogonalRenderer.js";
import TMXIsometricRenderer from "./level/tiled/renderer/TMXIsometricRenderer.js";
Expand All @@ -72,8 +74,6 @@ import World from "./physics/world.js";
import ParticleEmitter from "./particles/emitter.js";
import Particle from "./particles/particle.js";
import Entity from "./entity/entity.js";
import CollectableEntity from "./entity/collectable_entity.js";
import LevelEntity from "./entity/level_entity.js";
import DraggableEntity from "./entity/draggable.js";
import DroptargetEntity from "./entity/droptarget.js";

Expand Down Expand Up @@ -153,6 +153,8 @@ export {
ImageLayer,
Sprite,
GUI_Object,
Collectable,
Trigger,
TMXRenderer,
TMXOrthogonalRenderer,
TMXIsometricRenderer,
Expand All @@ -171,8 +173,6 @@ export {
ParticleEmitter,
Particle,
Entity,
CollectableEntity,
LevelEntity,
DraggableEntity,
DroptargetEntity
};
Expand Down Expand Up @@ -223,8 +223,8 @@ export function boot() {

// register all built-ins objects into the object pool
pool.register("me.Entity", Entity);
pool.register("me.CollectableEntity", CollectableEntity);
pool.register("me.LevelEntity", LevelEntity);
pool.register("me.Collectable", Collectable);
pool.register("me.Trigger", Trigger);
pool.register("me.Tween", Tween, true);
pool.register("me.Color", Color, true);
pool.register("me.Particle", Particle, true);
Expand All @@ -249,8 +249,8 @@ export function boot() {

// duplicate all entries if use with no namespace (e.g. es6)
pool.register("Entity", Entity);
pool.register("CollectableEntity", CollectableEntity);
pool.register("LevelEntity", LevelEntity);
pool.register("Collectable", Collectable);
pool.register("Trigger", Trigger);
pool.register("Tween", Tween, true);
pool.register("Color", Color, true);
pool.register("Particle", Particle, true);
Expand Down
36 changes: 35 additions & 1 deletion src/lang/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function warning(deprecated, replacement, version) {
/** @ignore */
init: function (settings) {
// super constructor
this._super(me.Stage, "init", settings);
this._super(me.Stage, "init", [settings]);
// deprecation warning
warning("me.ScreenObject", "me.Stage", "6.2.0");
}
Expand Down Expand Up @@ -905,4 +905,38 @@ export function warning(deprecated, replacement, version) {
configurable : false
});

/**
* @class me.CollectableEntity
* @deprecated since 9.0.0
* @see me.Collectable
*/
me.CollectableEntity = me.Collectable.extend({
/** @ignore */
init: function (x, y, settings) {
// super constructor
this._super(me.Collectable, "init", [x, y, settings]);
// deprecation warning
warning("me.CollectableEntity", "me.Collectable", "9.0.0");
}
});

/**
* @class me.LevelEntity
* @deprecated since 9.0.0
* @see me.Trigger
*/
me.LevelEntity = me.Trigger.extend({
/** @ignore */
init: function (x, y, settings) {
// super constructor
this._super(me.Trigger, "init", [x, y, settings]);
// deprecation warning
warning("me.LevelEntity", "me.Trigger", "9.0.0");
}
});

// corresponding entry in the object pool
me.pool.register("me.CollectableEntity", me.CollectableEntity);
me.pool.register("me.LevelEntity", me.LevelEntity);

};
42 changes: 42 additions & 0 deletions src/renderable/collectable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import Sprite from "./sprite.js";
import Body from "./../physics/body.js";
import collision from "./../physics/collision.js";

/**
* a basic collectable helper class for immovable object (e.g. a coin)
* @class
* @extends me.Sprite
* @memberOf me
* @constructor
* @param {Number} x the x coordinates of the collectable
* @param {Number} y the y coordinates of the collectable
* @param {Object} settings See {@link me.Sprite}
*/
var Collectable = Sprite.extend({
/**
* @ignore
*/
init : function (x, y, settings) {
// call the super constructor
this._super(Sprite, "init", [x, y, settings]);

this.name = settings.name;
this.type = settings.type;
this.id = settings.id;

// add and configure the physic body
this.body = new Body(this, settings.shapes || this.getBounds());
this.body.collisionType = collision.types.COLLECTABLE_OBJECT;

// Update anchorPoint
if (settings.anchorPoint) {
this.anchorPoint.set(settings.anchorPoint.x, settings.anchorPoint.y);
} else {
// for backward compatibility
this.anchorPoint.set(0, 0);
}

}
});

export default Collectable;
Loading

0 comments on commit 493d9e0

Please sign in to comment.