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 #8

Closed
FlixelCommunityBot opened this issue Sep 13, 2012 · 2 comments
Closed

FlxTilemap.ray() Result value always null #8

FlixelCommunityBot opened this issue Sep 13, 2012 · 2 comments

Comments

@FlixelCommunityBot
Copy link

Issue #224 by: cr0ybot

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?

@FlixelCommunityBot
Copy link
Author

Comment by: moly

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.
@IQAndreas
Copy link
Member

Resolved by commit e5a7345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants