Skip to content

Commit

Permalink
#63: Adds generic Item class WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
saricden committed Apr 20, 2019
1 parent 0d1fe1d commit ffbe738
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
Binary file added src/assets/images/sprites/test-items/PMD.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/sprites/test-items/cog.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions src/sprites/base/Item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {GameObjects} from 'phaser';

const {Sprite} = GameObjects;

class Item extends Sprite {
constructor(config) {
super(config.scene, config.x, config.y, config.key);

// Add self to scene's physics
config.scene.physics.world.enable(this);
config.scene.add.existing(this);

this.setTexture(config.texture);

this.isUI = false;
}
}

export default Item;
12 changes: 12 additions & 0 deletions src/sprites/static/items/Cog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Item from '../../base/Item';

class Cog extends Item {
constructor(config) {
super({
...config,
texture: 'item-cog'
});
}
}

export default Cog;

0 comments on commit ffbe738

Please sign in to comment.