Created
March 17, 2016 13:29
-
-
Save andrewmunro/8b2134cfdc9998d9b27e to your computer and use it in GitHub Desktop.
Bamboo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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