Code Monkey home page Code Monkey logo

Comments (5)

borkowsky avatar borkowsky commented on August 17, 2024 1

Thanks for the answers, i just need to use getPosition method.

from grid-engine.

Annoraaq avatar Annoraaq commented on August 17, 2024

Hi @borkowsky, I assume you mean that the moveLeft, moveRight, etc. methods?
They always return undefined on purpose.
What do you suggest them to return instead?

from grid-engine.

borkowsky avatar borkowsky commented on August 17, 2024

Hi @borkowsky, I assume you mean that the moveLeft, moveRight, etc. methods?
They always return undefined on purpose.
What do you suggest them to return instead?

Maybe return new position?

from grid-engine.

Annoraaq avatar Annoraaq commented on August 17, 2024

The problem is, that they are not synchronous methods. You can see them more as a "fire and forget" command.
A good comparison would be to see them like a keypress in a game. You can press the key as often as you want and the game will notice, but it will decide whether or not a keypress is changing the player position or not.

In this plugin it is as follows: if you take a look at the "move-player" example you see that a pressed key will trigger a call to on e of the move methods on every update. But not each of these calls causes a position change. They only tell the game that you would like to move a player.

Therefore it is not possible to return a new position. But if you tell me what you need it for, I can maybe tell you how to achieve this differently. And if not possible, I could extend the plugin in a way that helps you and other users.

Since Version 1.4 there are some observables that you can use to react to events like movementStarted, movementStopped or directionChanged.

from grid-engine.

Annoraaq avatar Annoraaq commented on August 17, 2024

You're welcome. I am playing with the thought of adding an observable that fires on every position change. Depending on your use case that could prevent you from polling.

from grid-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.