Git Product home page Git Product logo

Comments (2)

Viglino avatar Viglino commented on May 12, 2024

You can listen to changes on the sprite geometry to know its position:

plane.getGeometry().on('change', function (e) {
  var pos = e.target.getCoordinates();
  // Do something with that position
  ...
});

If you're looking for the position on the path for the sprite:

  • plane.path is the path it is moving along
  • plane.destination is the index of the point on the path the plane is going to

You can listen to change:direction events to know when the sprite is moving along a new segment on the path:

plane.on('change:direction', function(e) {
  console.log('plane is on the '+e.target.destination+' segment');
  console.log('plane is going to '+e.target.path[plane.destination]);
});

I could have make it more clear and return the destination in the change:direction event.

from ol-games.

ergin-duran avatar ergin-duran commented on May 12, 2024

Thank you @Viglino . You're awesome! I was scared if i call something getClosest method for this, view.setcenter maybe gets lag/delay. But there's already a destination counter for linestring path.

Hope you help me about styling CanvasTitle. I still couldn't handle it. I want to add a logo/image and long text maybe 2-3 lines near on it. But i am still stuck there.
https://github.com/Viglino/ol-ext/issues/320#issuecomment-515687418

from ol-games.

Related Issues (15)

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.