Giter Site home page Giter Site logo

Comments (3)

bberak avatar bberak commented on May 22, 2024

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.

majonathany avatar majonathany commented on May 22, 2024

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.

bberak avatar bberak commented on May 22, 2024

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)

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.