Comments (6)
Update: The disappearing issue appears to be a related to collisions with multiple rectangles at the same time.
For testing, I made only a single block collideable, and the r1 sprite no longer disappears.
However, even with a single tile only colliding, the r1 sprite is moved left until they are dumped off the tile.
from bump.
I'm new to Hexi, so this may be a dumb question - but why are you calling hitTestRectangle first? Surely this will only prevent things overlapping if they are already colliding. What if the player is not colliding with the tiles already, and moves fast enough to pass through?
from bump.
@jbockmon Have to seen the platformer example here?
https://github.com/kittykatattack/hexi/blob/master/examples/src/platforms.js
from bump.
@JamesCraster: you're correct, in this case there's no need to call hitTestRectangle
- a simple rectangleCollision
will do.
from bump.
@JamesCraster the algorithms for detecting collisions in hitTestRectangle and rectangleCollision are different. Furthermore. hitTestRectangle does not alter sprite vx or vy directly, nor does it alter its x or y coords. rectangleCollision, on the other hand, checks for collisions as well as handles sprite movement/correction to prevent collision.
When I relied on rectangleCollision alone, the algorithm it employs returns left/right collisions as well as bottom/top collisions when the lhs sprite spans two or more blocks/sprites. Because rectangleCollision directly modifies the vx and vy values, these left/right collisions would stop my lhs sprite from being able to move. I use hitTestRectangle to filter the unncessary left/right collisions out to prevent it from setting lhs.vx to 0.
from bump.
@kittykatattack I have not. I will have to check it out. Thanks!
from bump.
Related Issues (15)
- package.json! HOT 2
- No support for hitArea? HOT 1
- Polygon collision
- I think the function 'hit' doesn't work as expect in some cases
- setup via module system HOT 1
- hitTestCircleRectangle is returning false. (It shouldn't do this)
- contain uses mixed positioning
- error in findCollisionType
- Still maintained? HOT 5
- It can't support sprite collision? HOT 2
- Add rotation support HOT 2
- License HOT 2
- setting up start time of tween curve HOT 1
- Deprecation Warning: The ParticleContainer class has been moved to particles.ParticleContainer, please use particles.ParticleContainer from now on HOT 5
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 bump.