Skip to content

Instantly share code, notes, and snippets.

@andrewmunro
Created March 17, 2016 13:29
Show Gist options
  • Save andrewmunro/8b2134cfdc9998d9b27e to your computer and use it in GitHub Desktop.
Save andrewmunro/8b2134cfdc9998d9b27e to your computer and use it in GitHub Desktop.
Bamboo
import React from 'react';
import {Stage, Text, Sprite} from 'react-pixi';
import config from 'config'
import GameScene from 'components/GameScene';
class AppComponent extends React.Component {
get currentScene() {
return GameScene;
}
render() {
let CurrentScene = this.currentScene;
return (
<div className="index">
<Stage width={config.stage.width} height={config.stage.height}>
<CurrentScene/>
</Stage>
</div>
);
}
}
AppComponent.defaultProps = {};
export default AppComponent;
import React from 'react';
import {Stage, Text, Sprite} from 'react-pixi';
import {Point} from 'pixi.js';
import Scene from 'components/scene/Scene';
import Camera from 'components/scene/camera/Camera';
import config from 'config'
import TileMap from 'components/TileMap';
import bunny from 'images/bunny.png';
class GameScene extends Scene {
constructor(props) {
super(props);
this.state = {};
}
get renderer() {
//Split screen cameras
return (
<Camera
width={config.stage.width / 2}
height={config.stage.height / 2}/>
<Camera
width={config.stage.width / 2}
height={config.stage.height / 2}
x={config.stage.width / 2}
y={config.stage.height / 2} />
)
}
render() {
let bunnyX = config.stage.width / 2,
bunnyY = config.stage.height / 2 - 100;
return (
<DisplayObjectContainer>
<Sprite image={bunny} x={bunnyX} y={bunnyY}/>
<TileMap map="assets/desert.json"/>
<Text text="Hello World"
x={config.stage.width / 2}
y={config.stage.height / 2}
anchor={new Point(0.5,0)}
key="2"/>
</DisplayObjectContainer>
);
}
}
export default GameScene;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment