Jump to content

Problems to collide with tilemap


matheusmauer
 Share

Recommended Posts

Hi Folks, im trying to do a kind of Mini Golf game, im using the 'tiled map editor' to make the map of my game, but is not working like i expect.

 

 

http://aula.inf.poa.ifrs.edu.br/~0196142/JogoDeGolf/

 

I try everythin that was mentioned in tutorials:

 

http://aula.inf.poa.ifrs.edu.br/~0196142/JogoDeGolf/game.js

 

 

Someone can help-me?

 

 

Sorry for the incorrect english usage!

Link to comment
Share on other sites

huh..  actually .. i don't know where to start..   first of all you mix arcade physics with p2 physics in a weird way...     an arcade body can not collide with a p2 body afaik.

 

then you enable p2 AND arcade for "player"   - i believe this is not possible

 

then you introduce collisionGroups for the player...  the moment you activate collisiongroups nothing collides anymore.. you will have to give collisiongroups to everything that should collide again.  that means your tile bodies too...

game.physics.p2.convertTilemap(map, layer);

this creates an array of bodies from your tilemap..  you need to cycle over them in a for loop and apply a collisiongroup to all the bodies if you want them to collide with your player...  

Link to comment
Share on other sites

Yeah, i made this because i wanna do a differente behavior to the hole: use collision groups to fade with the ball when it collide with the hole.

But my first problem now is the walls.

 

Sorry for the messed code, but i'm trying everything that I see on internet.

 

I Fix some staffs and put the 'convertTilemap', but didnt change anything:

http://aula.inf.poa.ifrs.edu.br/~0196142/Teste2/indexe.html

 

I cant do collision groups with arcade mode?

Link to comment
Share on other sites

no you can't...   please have a look at your browsers console.. it shows at least the obvious errors..  like "this.map"  should be just "map" and ther is no cache-key "map" for an image...

 

you can not give the player an arcade body and the tilemap tiles p2 bodies..   chose either one otherwise they won't collide..  

 

it's probably best you stick completely to arcade physics for now..   

Link to comment
Share on other sites

i just tried your game again..  seems that you get it done right now :)

 

unfortunately i just figured that you will not be happy with arcade physics in your case because arcade supports aabb shapes only.. rectangles... you definitely need a circle...  and diagonal shapes (polylines) so you should probably go with p2 physics.. even if its a little bit harder at the beginning.

Link to comment
Share on other sites

Well, theres no way to do a tilemap in diagonal?

or make the phaser recognize some object layer?

 

 

Another doubt that i have is, are another 'launcher follows' on phaser?

cause in my game there's a problem, the ball is pushed and not pulled:

 

i dont know how to do something like this guy did:

http://janpeter.net/golf/

 

I try to copy his code, but i dont understand nothing at all.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...