Giter Site home page Giter Site logo

Comments (3)

iUltimateLP avatar iUltimateLP commented on June 12, 2024

Update: it seems that calling setOrigin(0.5) on the sprite in update() serves as a workaround, although that might not be optimal!

from grid-engine.

Annoraaq avatar Annoraaq commented on June 12, 2024

Hey @iUltimateLP, happy to hear you like Grid Engine.

I know why your problem happens, but I am not sure about the best way to solve it.

Grid Engine sets the origin to (0,0). It needs to know the origin in order to place the sprite correctly to the center of the tile. I think it would not be a problem to change the origin to something else, but then someone who wants to have an origin of (0,0) has the same problem you experience now.

The first solutions coming to my mind would be:

  1. Grid Engine could store the original origin and only set its own one for repositioning the sprite and then set the old origin afterwards again (basically what you are doing as a workaround right now). The fact that your workaround works, is an indicator that this solution should work.

  2. Let Grid Engine detect the origin and calculate the positioning of the sprite in relation to the origin.

I tend to favor option 1 over 2, because 2 is probably more complex.

I am also open for more ideas.

from grid-engine.

Annoraaq avatar Annoraaq commented on June 12, 2024

I tried resetting the origin after applying the pixel position changes but it leads to a wrong positioning of the sprite. I can't see a better solution than your workaround in cases where you need an origin different from (0,0).

I will close this for now but feel free to reopen if you have more suggestions.

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.