GithubHelp home page GithubHelp logo

Comments (11)

micahkatz avatar micahkatz commented on May 5, 2024

@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.

kjin9174 avatar kjin9174 commented on May 5, 2024

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 (



<p
className="start"
style={{ display: this.state.blink ? 'block' : 'none' }}
>
Press Start



);
}

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.

micahkatz avatar micahkatz commented on May 5, 2024

Read this in order to better understand how this library works

from react-game-kit.

kjin9174 avatar kjin9174 commented on May 5, 2024

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.

micahkatz avatar micahkatz commented on May 5, 2024

what do you need to animate?

from react-game-kit.

kjin9174 avatar kjin9174 commented on May 5, 2024

right going and left going animation,sir

from react-game-kit.

kjin9174 avatar kjin9174 commented on May 5, 2024

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.

kjin9174 avatar kjin9174 commented on May 5, 2024

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.

micahkatz avatar micahkatz commented on May 5, 2024

what are you animating?

from react-game-kit.

kjin9174 avatar kjin9174 commented on May 5, 2024

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.

ryan-roemer avatar ryan-roemer commented on May 5, 2024

Closing as we don't have a specific issue here, and it's been a while :)

from react-game-kit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.