Comments (3)
Hi @majonathany,
The renderer
for each entity should be instantiated properly, and passed all the properties of its parent entity via the props
object.
I think you're close/on the right track:
_getEntities = () => {
if (this.state.currentLevel === 1) {
return {
physics: {engine: this.state.engine, world: this.state.world},
currentItem: {
body: this.state.currentItem,
typeName: "currentItem",
renderer: Character,
recycleBin: {
body: this.state.bins.recycleBin,
typeName: "recycleBin",
renderer: Character,
trashCan: {
body: this.state.bins.trashCan,
typeName: "trashCan",
renderer: Character
};
}
};
Your Character
code should not require any change. That said, it's worth noting that your Character
functional component will be re-rendered on each frame because functional components are harder to optimize than classes (I believe this shortcoming can be alleviated in the recent versions fo React). React classes give you the ability to inherit from PureComponent
or provide an additional shouldComponentUpdate
lifecycle method that allows you to help React determine whether a component should be re-renderered or not. Might not be worth worying about now, but just keep it in mind if you need to optimize for performance in the future..
Let me kow if that helps!
from react-native-game-engine.
Thank you so much @bberak. I'm working on a project for a client that involves three games and has a bunch of database backend stuff. This library has saved my life and was pretty much the only option. This issue is resolved. Do you think I should keep it open if I have more questions or close this issue?
from react-native-game-engine.
Awesome @majonathany, I'm glad it has helped! Would love to hear more about your project when it is completed or has been released.. All the best with the rest of the development, and don't hesitate to open another issue if required (I'm going to close this one out to keep things organised).
from react-native-game-engine.
Related Issues (20)
- Is it possible to use phaser with react-native-game-engine? HOT 4
- Touch array is empty in iOS HOT 1
- Functions not in TypeScript definition files HOT 8
- How can i catch in Entity onPress event and value on System.js HOT 3
- Custom fonts used inside GameEngine not working
- Default timer doesn't stop when calling `.stop()` HOT 3
- Nested entity property change doesn't trigger rerender process HOT 3
- How to use TouchEvent for continious handelrs? HOT 1
- Systems functions
- FPS issues HOT 9
- Add animation for moving HOT 10
- Best Way to handle touch as directional control HOT 3
- Support for Expo SDK 43, 44, 45 HOT 7
- Cant handle multitouch operations and it is really slow HOT 4
- How to change Game Engine's coordinate ?
- Tilemap free pan
- while dragging create line like WordSearch game
- What type of game can i build???
- is there anyone who is maintaining this library yet? HOT 2
- GameEngine re-rendering on entities change HOT 3
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-native-game-engine.