Commit 9abebb1e authored by wildfirecode13's avatar wildfirecode13

1

parent eb25a193
import { Sprite, TextureCache } from 'spark-wrapper-fyge';
export default class DropItem extends Sprite {
constructor() {
constructor(props) {
super();
this.texture = TextureCache['box']
this.y = 0;
this.texture = TextureCache['box'];
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() {
this.y +=10;
onEnterFrame() {
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 Root from './Root';
import DropItem from './DropItem';
/**
*
*
*/
class GameStage extends WidgetBase {
onLaunched() {
// let label = new TextField();
// label.text = 'Hello CanvasWidget!';
// label.fillColor = '#000';
// label.size = 40;
// this.addChild(label);
this.drops = [];
this.stage.addEventListener(
Event.ENTER_FRAME,
this.onEnterFrame,
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