Comments (11)
@kjin9174 your body has to be inside of loop and stage and world. You should read the documentation in the readme
from react-game-kit.
thanks, Could you write code for very simple animation here,sir?
I don't understand, sorry.
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import logo from './logo.svg';
import intro from './assets/intro.png';
import './App.css';
import { Loop, Stage, World, Body } from 'react-game-kit';
import PropTypes from 'prop-types';
import{ AudioPlayer} from 'react-game-kit';
export default class Intro extends Component {
static propTypes = {
onStart: PropTypes.func,
};
constructor(props) {
super(props);
this.state = {
blink: false,
};
this.startUpdate = this.startUpdate.bind(this);
this.handleKeyPress = this.handleKeyPress.bind(this);
}
componentDidMount() {
this.startNoise = new AudioPlayer('/assets/start.wav');
window.addEventListener('keypress', this.handleKeyPress);
this.animationFrame = requestAnimationFrame(this.startUpdate);
this.interval = setInterval(() => {
this.setState({
blink: !this.state.blink,
});
}, 500);
}
componentWillUnmount() {
window.removeEventListener('keypress', this.handleKeyPress);
cancelAnimationFrame(this.animationFrame);
clearInterval(this.interval);
}
render() {
return (
);
}
startUpdate() {
this.animationFrame = requestAnimationFrame(this.startUpdate);
}
handleKeyPress(e) {
if (e.keyCode === 13) {
this.startNoise.play();
this.props.onStart();
}
}
}
this code is working
But what import code should i use for using tags in react-game-kit?????
from react-game-kit.
Read this in order to better understand how this library works
from react-game-kit.
I've already read it.
But i don't understand,sir. sorry.
Could you send here for simple animation code to me?
from react-game-kit.
what do you need to animate?
from react-game-kit.
right going and left going animation,sir
from react-game-kit.
with using
How should i import?
import { Loop, Stage, ...etc } from 'react-game-kit/native'; is not working in my end. error is coming
help me,sir
from react-game-kit.
i need your code of this format.sir
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import logo from './logo.svg';
import intro from './assets/intro.png';
import './App.css';
import { Loop, Stage, World, Body } from 'react-game-kit';
import PropTypes from 'prop-types';
import{ AudioPlayer} from 'react-game-kit';
export default class Intro extends Component {
static propTypes = {
onStart: PropTypes.func,
};
constructor(props) {
super(props);
this.state = {
blink: false,
};
this.startUpdate = this.startUpdate.bind(this);
this.handleKeyPress = this.handleKeyPress.bind(this);
}
componentDidMount() {
window.addEventListener('keypress', this.handleKeyPress);
this.animationFrame = requestAnimationFrame(this.startUpdate);
this.interval = setInterval(() => {
this.setState({
blink: !this.state.blink,
});
}, 500);
}
componentWillUnmount() {
window.removeEventListener('keypress', this.handleKeyPress);
cancelAnimationFrame(this.animationFrame);
clearInterval(this.interval);
}
render() {
return (
<img className="intro" src={intro} style={{height:500, width:800}}/>
<p
className="start"
style={{ display: this.state.blink ? 'block' : 'none' }}
>
Press Start
);
}
startUpdate() {
this.animationFrame = requestAnimationFrame(this.startUpdate);
}
handleKeyPress(e) {
if (e.keyCode === 13) {
}
}
}
from react-game-kit.
what are you animating?
from react-game-kit.
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import logo from './logo.svg';
import intro from './assets/intro.png';
import './App.css';
import { Loop, Stage, World, Body, Sprite } from 'react-game-kit';
import PropTypes from 'prop-types';
import{ AudioPlayer} from 'react-game-kit';
class App extends Component {
static contextTypes = {
loop: PropTypes.object,
};
loop = () => {
//Do stuff here
};
componentDidMount() {
this.loopID = this.context.loop.subscribe(this.loop);
}
componentWillUnmount() {
this.context.loop.unsubscribe(this.loopID);
}
render() {
return (
<Sprite
repeat={true}
src="./assets/intro.png"
scale={this.context.scale * 2}
state={0}
steps={[9, 9, 0, 4, 5]}
/>
);
}
}
export default App;
this is my code of app.js of my new react app. but it is not working.
so i need to know how i should fix.
from react-game-kit.
Closing as we don't have a specific issue here, and it's been a while :)
from react-game-kit.
Related Issues (20)
- Run into a problem with two or more sprites changing state simultaneously HOT 2
- Cannot read property 'subscribers' of undefined HOT 4
- Sprite Src Issue In RN HOT 2
- How can I remove the dependency on prop-types (as TypeScript provides type-safety already)?
- Replacing Loop div element with Fragment
- tilemap not updating when passed new array props
- Components should forward classNames HOT 1
- New context API HOT 1
- Keypress in demo fires twice for Firefox
- React Native: <Body><View> = Position disarray
- Sprite: switching repeat not working without changing state
- Does TileMap work with files like tiles.png
- Unit Test Mocks
- CRA 2.0 Issues
- How to create a component of falling shapes
- Current project status HOT 4
- Loop proptypes.object react-game-kit HOT 1
- Demo broken
- Archived? Whats the future on this? HOT 4
- Update build tooling infrastructure.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-game-kit.