Commit 9abebb1e authored by wildfirecode13's avatar wildfirecode13

1

parent eb25a193
import { Sprite, TextureCache } from 'spark-wrapper-fyge'; import { Sprite, TextureCache } from 'spark-wrapper-fyge';
export default class DropItem extends Sprite { export default class DropItem extends Sprite {
constructor() { constructor(props) {
super(); super();
this.texture = TextureCache['box'] this.texture = TextureCache['box'];
this.y = 0; this.velocityX = this.initialVelocityX = props.initialVelocityX || 0;
this.velocityY = this.initialVelocityY = props.initialVelocityY || 0;
this.accelerationX = props.accelerationX || 0;
this.accelerationY = props.accelerationY || 0;
} }
updatePosition() { onEnterFrame() {
this.y +=10; this.velocityX += this.accelerationX;
this.velocityY += this.accelerationY;
this.x += this.velocityX;
this.y += this.velocityY;
} }
} }
import { WidgetBase } from 'spark-wrapper-fyge'; import { WidgetBase, Event } from 'spark-wrapper-fyge';
import metaConfig from '../meta.json'; import metaConfig from '../meta.json';
import Root from './Root'; import DropItem from './DropItem';
/**
*
*
*/
class GameStage extends WidgetBase { class GameStage extends WidgetBase {
onLaunched() { onLaunched() {
// let label = new TextField(); this.drops = [];
// label.text = 'Hello CanvasWidget!'; this.stage.addEventListener(
// label.fillColor = '#000'; Event.ENTER_FRAME,
// label.size = 40; this.onEnterFrame,
// this.addChild(label); this
);
this.addDrops();
}
addDrops() {
const drop = new DropItem({
initialVelocityY: -50,
initialVelocityX: 10,
accelerationY:2
});
drop.y = 1000;
this.addChild(drop);
this.drops.push(drop);
}
this.addChild(new Root()); onEnterFrame() {
this.drops.forEach(i => i.onEnterFrame());
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment