Author Topic: Collision stops on my map after a certain part.  (Read 1814 times)

lordkuragari

  • Member
  • **
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Relevant code

Code: [Select]
override public function create():void

{
FlxG.bgColor =0xffaaaaaa;
level = new FlxTilemap();
level.loadMap(new testLevel,tiles,16,16,0,0,1,4);
add(level);
player = new Player(60,50);
add(player)
camera = new FlxCamera(0,0,320,240,0);
FlxG.camera.follow(player);
}

override public function update():void
{

super.update();
FlxG.collide(player,level);
}
<a href="http://gigablam.com/lilDeath.swf" target="_blank" rel="noopener noreferrer" class="bbc_link bbc_flash_disabled new_win">http://gigablam.com/lilDeath.swf</a>

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: Collision stops on my map after a certain part.
« Reply #1 on: Tue, Jul 12, 2011 »
I am finding out the Flixel 2.5 is a lot different to the last version of Flixel for Flash I was using but this was a problem for me when the player goes outside the world bounds.
Try
Code: [Select]
FlxG.worldBounds = new FlxRect(0, 0, tilemap.width, tilemap.height);
or to do a quick debug to see if this will resolve your problem

Code: [Select]
FlxG.worldBounds = new FlxRect(0, 0, 2000, 2000);
Keep in mind the bigger the world bounds, the more collision checks it will perform, potentially slowing down the frame rate.
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

lordkuragari

  • Member
  • **
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Collision stops on my map after a certain part.
« Reply #2 on: Tue, Jul 12, 2011 »
FlxG.worldBounds = new FlxRect(0, 0, tilemap.width, tilemap.height);

works but..... why do i have to do this?

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: Collision stops on my map after a certain part.
« Reply #3 on: Tue, Jul 12, 2011 »
Flixel needs to know what area to test for collisions in. If it were to test an infinite space it would take forever and you'd have an unplayable frame rate.

Without setting it, Flixel is using a default value, probably equal to FlxG.width and FlxG.height (I am assuming this), and such moving outside of this area cause collisions to no longer be calculated.
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

GrimPanda

  • Member
  • **
  • Posts: 46
  • Karma: +1/-0
    • View Profile
    • Grim Panda Games
Re: Collision stops on my map after a certain part.
« Reply #4 on: Wed, Jul 13, 2011 »
FlxG.worldBounds = new FlxRect(0, 0, tilemap.width, tilemap.height);

works but..... why do i have to do this?

This is always a good practice anyways in my opinion.  This was a standard line in any code I wrote previously. This rect shape makes many things a breeze too such as positioning game elements, and other little tidbits you'll discover as you make use of it. 
« Last Edit: Wed, Jul 13, 2011 by GrimPanda »
"Mortis Ailuropoda"

felipe

  • Member
  • **
  • Posts: 36
  • Karma: +0/-0
  • games!
    • View Profile
    • i love pixel
Re: Collision stops on my map after a certain part.
« Reply #5 on: Wed, Jul 13, 2011 »
on flixel 2.5 wouldn't youmapname.follow(); do the work?

Noonsa

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Collision stops on my map after a certain part.
« Reply #6 on: Wed, Jul 13, 2011 »
on flixel 2.5 wouldn't youmapname.follow(); do the work?

Yes, do this. As a newbie, I recently had this exact problem, and this is how I fixed it.

lordkuragari

  • Member
  • **
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Collision stops on my map after a certain part.
« Reply #7 on: Wed, Jul 13, 2011 »
well both solutions work... i wonder which is the better choice?

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: Collision stops on my map after a certain part.
« Reply #8 on: Wed, Jul 13, 2011 »
If you are using Flixel 2.5 or greater I think this is the new way to do it. I am still a newbie with 2.5 (you'd be surprised with how much changed.) so go with the follow command.

on flixel 2.5 wouldn't youmapname.follow(); do the work?
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart