Code Monkey home page Code Monkey logo

Comments (6)

SeiferTim avatar SeiferTim commented on June 20, 2024

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.

Dovyski avatar Dovyski commented on June 20, 2024

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.

SeiferTim avatar SeiferTim commented on June 20, 2024

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.

Dovyski avatar Dovyski commented on June 20, 2024

@moly @IQAndreas Do you guys agree with our thoughts? If so, I will close this issue and create a feature request.

from flixel.

IQAndreas avatar IQAndreas commented on June 20, 2024

Do you guys agree with our thoughts?

Yes, I think it's a swell idea. Go ahead and make the feature request.

from flixel.

Dovyski avatar Dovyski commented on June 20, 2024

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)

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.