Author Topic: moving a tileMap and collide problems  (Read 1588 times)

mutantlabs

  • Guest
moving a tileMap and collide problems
« on: Mon, Jun 28, 2010 »
I've had a good search and have had no luck in finding a solution,

Basically is there anyway to move a tileMap's position without breaking the collide function?

I've got a side scrolling platformer and want to use 2 tileMaps and when one goes off to the left, they are added to the right. as soon as this happens, colliding seems to stop working (for that tileMap).

Any Ideas?


three

  • Member
  • **
  • Posts: 71
  • Karma: +0/-0
    • View Profile
Re: moving a tileMap and collide problems
« Reply #1 on: Mon, Jun 28, 2010 »
i had the same problem with  moving tilemaps. after a while i found out that a refreshHulls(); and a new collide(whatever); for every tilemap in the update function fixes the problem.

i have no idea why but it works :)

libanes

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: moving a tileMap and collide problems
« Reply #2 on: Wed, Jul 28, 2010 »
I can't get this to work.

I create a tilemap in the playstate, set the y value to 40 and it breaks the collisions. I tried adding theTilemap.refreshHulls() and a .collide() in the playstate update function but it doesn't help. Help please.

I just want to move my tilemap down 40 pixels so it doesn't render at the top of the screen.

dolgion1

  • Guest
Re: moving a tileMap and collide problems
« Reply #3 on: Wed, Jul 28, 2010 »
What a coincidence, in my own post http://flixel.org/forums/index.php?topic=2109.0 i just requested a solution for the same problem.

Tried the suggestion with the refreshHulls() call, but it doesn't work for me either. According to the documentation, it seems to be made exactly for this problem. Weird...

zez

  • Active Member
  • ***
  • Posts: 203
  • Karma: +0/-0
    • View Profile
    • Devlog
Re: moving a tileMap and collide problems
« Reply #4 on: Wed, Jul 28, 2010 »
are you calling collide after refresh hulls? Also, does the player move useing velocity/acceleration/thrust, or are you manually altering there x & y coordinates?

libanes

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: moving a tileMap and collide problems
« Reply #5 on: Sun, Aug 1, 2010 »
are you calling collide after refresh hulls? Also, does the player move useing velocity/acceleration/thrust, or are you manually altering there x & y coordinates?

I've tried calling them in all possible orders and nothing seems to work.

The player is being moved by velocity.x & velocity.y

What happens is that all the collisions at the top works just like before, but at the bottom it breaks. My screen is 200 pixels in height, my tilemap is 160 pixels in height, so I move it down 40 pixels to be align at the bottom. What happens is that the collision for the last 40 pixels is gone, but above that it works perfect.

I'm not sure how the collisions work in Flixel, but it seems like I'm moving the tilemap out from some sort of main collision rectangle so that only the part of the tilemap that is still in it works.

zez

  • Active Member
  • ***
  • Posts: 203
  • Karma: +0/-0
    • View Profile
    • Devlog
Re: moving a tileMap and collide problems
« Reply #6 on: Sun, Aug 1, 2010 »
this might not fix anything, but try fiddling with FlxU.worldbounds. You also could work around it by just setting FlxG.followBounds....

dreamless

  • New Member
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: moving a tileMap and collide problems
« Reply #7 on: Sun, Aug 8, 2010 »
I had dolgion's problem.  Calling
Code: [Select]
FlxU.setWorldBounds( player.x - 200, player.y - 200, 400, 400 ); every frame right before my collide fixed it.  If it's a performance issue I could call it less often, but that takes more bookkeeping.