Comments (2)
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.
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)
- Examples are broken HOT 7
- unable to import FrameRate HOT 6
- Control animation with seeker bar HOT 3
- ol.Sprite.move() make misstakes when the direction is due east/ west/south HOT 3
- How to update image source of ol.Sprite ? HOT 5
- how to set sprite's name text style HOT 2
- HexMap error HOT 4
- Sprites freezes when scrolling or moving the map HOT 2
- Speed measure HOT 1
- Computer cup is too high HOT 1
- Example map.gameloop dont work? HOT 2
- How to draw a tail while a plane is flying? HOT 1
- OL 6 HOT 2
- HexMap rotation HOT 1
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 ol-games.