Comments (6)
So, the collide callback is returning the 2 objects that collided, in this case the Bullet that collided and the Tilemap Object itself.
So if you have your Tilemap at 0,0, then cmp.x will = 0 and cmp.y will = 0 in the callback...
If you want to know where INSIDE the tilemap that you collided, I think it's just a matter of some calculation... I don't think this is a bug that needs to be fixed, but maybe having a function that returns which tile(s) an object is overlapping within a Tilemap would be a helpful feature...
from flixel.
I agree with @SeiferTim and don't believe this is a bug. It could be useful to return the tile that is colliding, but it might break existing code. I think the best approach is to create a new FlxTilemap
method in the future.
from flixel.
Would someone want to mark this as 'Closed' and make a new Feature Request for a FlxTilemap function that returns the tile that is colliding with another object?
from flixel.
@moly @IQAndreas Do you guys agree with our thoughts? If so, I will close this issue and create a feature request.
from flixel.
Do you guys agree with our thoughts?
Yes, I think it's a swell idea. Go ahead and make the feature request.
from flixel.
I was writing the pull request for the enhancement we discussed here for FlxTilemap
and I noticed that FlxTilemap.overlapsWithCallback()
does exactly that:
/**
* Checks if the Object overlaps any tiles with any collision flags set,
* and calls the specified callback function (if there is one).
* Also calls the tile's registered callback if the filter matches.
*
* @param Object The <code>FlxObject</code> you are checking for overlaps against.
* @param Callback An optional function that takes the form "myCallback(Object1:FlxObject,Object2:FlxObject)", where Object1 is a FlxTile object, and Object2 is the object passed in in the first parameter of this method.
* @param FlipCallbackParams Used to preserve A-B list ordering from FlxObject.separate() - returns the FlxTile object as the second parameter instead.
* @param Position Optional, specify a custom position for the tilemap (useful for overlapsAt()-type funcitonality).
*
* @return Whether there were overlaps, or if a callback was specified, whatever the return value of the callback was.
*/
public function overlapsWithCallback(Object:FlxObject,Callback:Function=null,FlipCallbackParams:Boolean=false,Position:FlxPoint=null):Boolean
I think it does the trick, so there is no need for a new method.
from flixel.
Related Issues (20)
- Use bitwise operators for faster Math functions HOT 6
- Add FlxRandom seeded random generator HOT 13
- Add ray casting with soft shadows HOT 6
- Centralize all input handling in FlxG.input HOT 2
- Achievements in Flixel HOT 3
- FlxTween Enhancement HOT 11
- Overhaul the built-in debugger HOT 7
- Instantiable FlxColors HOT 6
- Community Notice Board HOT 3
- FlxTilemap() can't draw one-column tilemap - BitmaData exception HOT 4
- Create flixel-demos repository
- Bump version 2.58 to 3.0 HOT 2
- Add property "position" to FlxSprite HOT 4
- Implement FlxG.assets
- Dev branch lacks clear notice of Genome2d Dependency HOT 1
- Cannot get to compile against Genome2d SWC HOT 11
- FlxRandom has ASDoc validation errors HOT 3
- Context3D "Texture too big" error HOT 7
- [GPU build] calcFrame() wrong order HOT 2
- Current state of Flixel on GPU? HOT 3
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 flixel.