Author Topic: Very strange problem with colliding  (Read 1133 times)

boshkodj

  • Member
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Very strange problem with colliding
« on: Sat, Jul 23, 2011 »
I have very strange problem when I try to collide two FlxSprites.
The problem is that I set FlxCamera to follow one flxsprite ( player ). And when camera moves to right,
player falls down. Here is the example : http://www.newgrounds.com/dump/item/638e7e0fd11f144b4f15a468744eec56

Do you know what can be the problem? Thank you in advance!

lazyCrab

  • Member
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Re: Very strange problem with colliding
« Reply #1 on: Sun, Jul 24, 2011 »
I had that happen to me a few times, the level continues beyond the world bounds.
What you need to do is set the world bounds to the level size :

Code: [Select]
FlxG.worldBounds.right = level.getBounds().right;
FlxG.worldBounds.left = level.getBounds().left;
FlxG.worldBounds.top = level.getBounds().top;
FlxG.worldBounds.bottom = level.getBounds().bottom;

Where level is a FlxTilemap.
"WEEKS of programming can save HOURS of design"
"Programming today is a race betwin programmers trying to make bigger and vetter idiot proof programs and between the universe trying to make bigger and better idiots. Currently, the universe is winning"

boshkodj

  • Member
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: Very strange problem with colliding
« Reply #2 on: Sun, Jul 24, 2011 »
Here :

Code: [Select]
ground = new FlxSprite(0, 350).makeGraphic(2000, 20, 0xFF000000);
ground.immovable = true;
add(ground);

// player.
play = new Player(100, 100);
add(play);

FlxG.camera.setBounds(0, 0, 2000, GlobalProperties.GameHeight);
FlxG.camera.follow(play,FlxCamera.STYLE_PLATFORMER);

and it's not working, again player falls down. I totally can't figure out why he falls!

lazyCrab

  • Member
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Re: Very strange problem with colliding
« Reply #3 on: Sun, Jul 24, 2011 »
I allready told you ... not camera bounds WORLD BOUNDS !!! FLXG.WORLDBOUNDS!!!
"WEEKS of programming can save HOURS of design"
"Programming today is a race betwin programmers trying to make bigger and vetter idiot proof programs and between the universe trying to make bigger and better idiots. Currently, the universe is winning"

boshkodj

  • Member
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: Very strange problem with colliding
« Reply #4 on: Sun, Jul 24, 2011 »
Property is read-only

lazyCrab

  • Member
  • **
  • Posts: 46
  • Karma: +0/-0
    • View Profile
Re: Very strange problem with colliding
« Reply #5 on: Sun, Jul 24, 2011 »
No it isn't .... Thats what I did and it worked perfectly for me. Look :

Quote
worldBounds : FlxRect
[static] The dimensions of the game world, used by the quad tree for collisions and overlap checks.

And that's directly from the docs
"WEEKS of programming can save HOURS of design"
"Programming today is a race betwin programmers trying to make bigger and vetter idiot proof programs and between the universe trying to make bigger and better idiots. Currently, the universe is winning"

alejoamiras

  • Member
  • **
  • Posts: 63
  • Karma: +0/-1
    • View Profile
Re: Very strange problem with colliding
« Reply #6 on: Sun, Jul 24, 2011 »
This is my Map.as and works perfectly :)

Code: [Select]
package 
{
import org.flixel.*;
/**
* ...
* @author Alejo Amiras
*/
public class Map extends FlxTilemap
{
private var _Mapa:int;
private var _WolrdWidth:int;
private var _WorldHeight:int;

public function Map(Mapa:int)
{
super();
setMapa(Mapa);
cargarMapa();
}
private function cargarMapa():void {
switch(getMapa()) {
case 0:
loadMap(new Registry.GfxSprites.Mapa1Csv, Registry.GfxSprites.Tiles , 16, 16, OFF);
break;
case 2:
//loadMap(new Registry.GfxSprites.Mapa2Csv, Registry.GfxSprites.Tile , 16, 16, OFF);
break;
}
setWorldWidth(this.width);
setWorldHeight(this.height);
}
public function setMapa(Mapa:int):void {
_Mapa = Mapa;
}
public function getMapa():int {
return _Mapa;
}
public function setWorldWidth(WorldWidth:int):void{
_WolrdWidth = WorldWidth;
FlxG.worldBounds.width = WorldWidth;
}
public function getWorldWidth():int {
return _WolrdWidth;
}
public function setWorldHeight(WorldHeight:int):void {
_WorldHeight = WorldHeight;
FlxG.worldBounds.height = WorldHeight;
}
public function getWorldHeight():int {
return _WorldHeight;
}

}

}

And after creatign my map I input the Camera bounds :)

Code: [Select]
Mapa = new Map(0);
add(Mapa);
Camara.setBounds(0, 0, Mapa.getWorldWidth()+960, Mapa.getWorldHeight()+600);

I hope this could help you.

c023-DeV

  • Game Artisan
  • Active Member
  • ***
  • Posts: 176
  • Karma: +0/-0
    • View Profile
    • DeV-ZoO
Re: Very strange problem with colliding
« Reply #7 on: Sun, Jul 24, 2011 »
Hi,
Im still kinda new to Flixel but I had the same issue, Try:

Code: [Select]
// this sets the limits of where the camera goes so that it doesn't show what's outside of the tilemap
cam.setBounds(0,0,_level.boundsMaxX, _level.boundsMaxY, true);

the TRUE at the end is your problem I recon...
@param   UpdateWorld      Whether the global quad-tree's dimensions should be updated to match (default: false)

(It helped for me, fingers crossed, good luck =)
If you aint got no dedication, you won't get no education!