Re: Collision for TMX map

23 views
Skip to first unread message

si...@nekapuzer.at

unread,
Jul 6, 2015, 2:01:48 AM7/6/15
to gam...@googlegroups.com
Hi Gamer,
gamejs doesn't have tmx collisons in its library, yet.

The gist you found looks good, though. Could it be that your browser just doesn't have the `forEach` method on arrays? This snippet was written for modern browsers only, it seems.

cu
 simon

July 5 2015 9:25 PM, "Gamer" <gampro...@gmail.com> wrote:
Hello, new to this group.  Hope I can help people along the way as much as I can!
Does gamejs support collision data from TMX files?   The only thing I can find is this: https://gist.github.com/oberhamsi/4006869 which does not seem to work as the "tmxMap" does not have .layers.forEach.
I was wondering if gamejs natively support collision Objects from Tiled Map Editior, and if not, how one would go about implementing such a thing.
Thanks.
--
You received this message because you are subscribed to the Google Groups "GameJs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gamejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gamer

unread,
Jul 7, 2015, 9:27:46 AM7/7/15
to gam...@googlegroups.com
Thank you for getting back to me Simon.

I have the latest Chrome/Firefox build.  No idea whats is wrong...

Gamer

unread,
Jul 8, 2015, 11:16:52 AM7/8/15
to gam...@googlegroups.com
Simon,
Any idea on what is wrong?  Maybe I am calling the function wrong...  Seems to me the tmxMap that I call with has no arrays in tmxMap.layers.  From my understanding, forEach will only work if the calling of it is used with an array...

Any help would be appreciated.

Thanks.

On Sunday, July 5, 2015 at 11:01:48 PM UTC-7, Simon Oberhammer wrote:

si...@nekapuzer.at

unread,
Jul 8, 2015, 2:27:47 PM7/8/15
to gam...@googlegroups.com
Hi Gamer,
i really can't tell what's going on. Could you fire up the debugger in your browser and when it breaks on the exception, you can inspect what value the "layers" variable has at that point. And the stack trace will tell you who is calling it with wrong arguments.

hope that helps,
 simon

Gamer

unread,
Jul 8, 2015, 4:39:04 PM7/8/15
to gam...@googlegroups.com
Hey Simon I figured it out.

In the examples for rendering tmx maps: https://github.com/GameJs/gamejs/tree/master/examples/tmxmap -- it will cause problems because you dont need this:


var Map = exports.Map = function(url) {

Since its already declared in the "var tiledmap = require('gamejs/tiledmap');" you include in the JS code.  Not including that you just call it normally...

 var map = new tiledmap.Map('TMXFILE');
 
var mapView = new tiledmap.MapView(map);
...
function render_map ( display ) {
 mapView
.draw ( display, [ 0 , 0 ] );
}


Anyway, after figuring that out I was able to make the call:

var collisionmapinfo = new tmxCollision.CollisionMap ( map );

Which works great!  Im guessing the variable map was being overwritten.

But alas, now the collision.js code moveTest needs certain arguments for the call which I need to figure out!

Thanks!
Reply all
Reply to author
Forward
0 new messages