Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlxTilemap.ray() Result value always null #224

Open
cr0ybot opened this issue Apr 13, 2012 · 1 comment
Open

FlxTilemap.ray() Result value always null #224

cr0ybot opened this issue Apr 13, 2012 · 1 comment

Comments

@cr0ybot
Copy link

cr0ybot commented Apr 13, 2012

Supposedly AS3 passes all objects as reference, but this does not appear to be the case with the "Result" FlxPoint in FlxTilemap.ray(). Checking the Result value always results in null.

See this stackoverflow question for a very similar situation:
http://stackoverflow.com/questions/3708371/actionscript-pass-by-reference

Why is it necessary to do the raycast in this manner? Why return a boolean at all if you can just return the FlxPoint (if the ray hits anything) and check for null?

@moly
Copy link

moly commented Aug 28, 2012

I don't think the error is with flixel here. This code:

var result:FlxPoint = new FlxPoint();
tile.ray(startPoint, endPoint, result);
trace(result.x + " " + result.y);

works fine for me. I think you were probably doing this:

var result:FlxPoint;
tilemap.ray(startPoint, endPoint, result);

which is essentially just passing null as the third parameter and will always give you null back.

moly added a commit to moly/flixel that referenced this issue Sep 16, 2012
… always null

I believe this issue was caused by the user mistakenly passing in a null pointer. I've just updated the code slightly to make it more obvious how it works, and to remove an unnecessary FlxPoint creation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants