Author Topic: Using Box2D in flixel [Tutorial]  (Read 5796 times)

phmongeau

  • Member
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Using Box2D in flixel [Tutorial]
« on: Wed, Jun 16, 2010 »
I wrote a tutorial on the new awesome Flash Game Dojo website.

http://flashgamedojo.com/wiki/index.php?title=Implementing_Box2D%28Flixel%29

I'm not totally finished, but I think you can get something working with it. I just need someone to try it and confirm that I didn't forget something important.

Also, since it's a wiki, if there's have any thing you'd want to change, feel free to do it.

ywp

  • Member
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Using Box2D in flixel [Tutorial]
« Reply #1 on: Wed, Jun 16, 2010 »
I've only just skimmed through it, but it looks like a great place to start.  I'll definitely be putting some time aside for this.  Thanks.

phmongeau

  • Member
  • **
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Re: Using Box2D in flixel [Tutorial]
« Reply #2 on: Wed, Jun 16, 2010 »
I've only just skimmed through it, but it looks like a great place to start.  I'll definitely be putting some time aside for this.  Thanks.

I don't think it a good place to start if you never made anything else with flixel. You really should start by something simpler like the HelloWorld or a simple game.

There's a bunch of thing I assume you already know.

But you can always try! :)

krix

  • Member
  • **
  • Posts: 61
  • Karma: +0/-0
    • View Profile
Re: Using Box2D in flixel [Tutorial]
« Reply #3 on: Wed, Jun 16, 2010 »
This is so awseome! Thank you very much!

Garmichael

  • Member
  • **
  • Posts: 89
  • Karma: +0/-0
    • View Profile
Re: Using Box2D in flixel [Tutorial]
« Reply #4 on: Thu, Jun 17, 2010 »
Very nice! I'll try this out with my next game

3WG

  • Active Member
  • ***
  • Posts: 110
  • Karma: +0/-0
    • View Profile
    • Jeux.MU
Re: Using Box2D in flixel [Tutorial]
« Reply #5 on: Sun, Jun 20, 2010 »
Very NIIIIIIIIIIICCCCCCCCCCCCCCCEEEE !!

I't work great for me.

Just awesome.
Flash games are FUN !
Jeux.MU

CosMind

  • Member
  • **
  • Posts: 6
  • Karma: +0/-0
  • stuff 'n stuff
    • View Profile
    • Glum Buster
Re: Using Box2D in flixel [Tutorial]
« Reply #6 on: Mon, Aug 2, 2010 »
solid tutorial.  high5.  i got everything working up to this point:

Quote
Getting the world to run

The only problem right now is that nothing moves. That's because we need to tell Box2D to update the world when Flixel runs its update.[/s]

Code: [Select]
override public function update():void
{
    _world.Step(FlxG.elapsed, 10, 10);
}

If you run the game, you should get a cube falling on a platform and bouncing.

but i'm scratching my head now...

i assume that you mean to insert that update override in what you call the "PlayState"?  if that's the case, then i'm not getting any results.  my beautiful cube doesn't fall/move/do anything.  is that update override not intended for the "PlayState"?


edit
problem soooooooooolved.  not your fault at all, good sir phmongeau.
« Last Edit: Mon, Aug 2, 2010 by CosMind »

xhunterko

  • Contributor
  • ****
  • Posts: 449
  • Karma: +0/-0
    • View Profile
Re: Using Box2D in flixel [Tutorial]
« Reply #7 on: Mon, Aug 2, 2010 »
Yes, I do have a problem.

I got all the way to here:

Code: [Select]
override public function create():void
{
    //Set up the world
    setupWorld();
}

Or here:

Code: [Select]
private function setupWorld():void
{
    var gravity:b2Vec2 = new b2Vec2(0, 9.8);
    _world = new b2World(gravity, true);
}
 

And the b2Vec2 was throwing errors on 9 documents of the API itself. All the errors had something to do with the part where the file called for a reference to "vector". I have no idea why and I haven't yet gone to the Box2d forums to report yet.

So let me know if any of you come up to this so I know I'm not the only one with this problem. And if you don't have any errors, what are you doing that I'm not?
« Last Edit: Mon, Aug 2, 2010 by xhunterko »
Now on twitter: http://twitter.com/xhunterko I made a game that's in alpha you can buy here: http://xhunterko.itch.io/wave-miner-alpha

Tyranus

  • Member
  • **
  • Posts: 54
  • Karma: +0/-0
    • View Profile
    • Tyranus:: Indie Games.
Re: Using Box2D in flixel [Tutorial]
« Reply #8 on: Mon, Aug 2, 2010 »
Yes, I do have a problem.

I got all the way to here:

Code: [Select]
override public function create():void
{
    //Set up the world
    setupWorld();
}
Or here:

Code: [Select]
private function setupWorld():void
{
    var gravity:b2Vec2 = new b2Vec2(0, 9.8);
    _world = new b2World(gravity, true);
}
 

And the b2Vec2 was throwing errors on 9 documents of the API itself. All the errors had something to do with the part where the file called for a reference to "vector". I have no idea why and I haven't yet gone to the Box2d forums to report yet.

So let me know if any of you come up to this so I know I'm not the only one with this problem. And if you don't have any errors, what are you doing that I'm not?

If you are using FlashDevelop, you must set up your  target as Flash Player 10.1.

Project -> Properties -> output -> target = Flash Player 10.1

This happen because the vectors are using a new type of declaration, that only exists in latest version of flash player.

Greetings!

xhunterko

  • Contributor
  • ****
  • Posts: 449
  • Karma: +0/-0
    • View Profile
Re: Using Box2D in flixel [Tutorial]
« Reply #9 on: Mon, Aug 2, 2010 »
Well, that solves those errors. Whether or not it solves my general problems I'll have to wait and see. By the way I have two things to ask about:

Quote
A FlxTileblock shouldn't need to move, so we won't change the update function.

But what if it does? Or it needs to rotate?

Also, this:

Quote
You can also try this little demo.

Gives me a 403 Forbidden when linked to. Which is a shame, i'd of liked to have seen it work.
Now on twitter: http://twitter.com/xhunterko I made a game that's in alpha you can buy here: http://xhunterko.itch.io/wave-miner-alpha

xhunterko

  • Contributor
  • ****
  • Posts: 449
  • Karma: +0/-0
    • View Profile
Re: Using Box2D in flixel [Tutorial]
« Reply #10 on: Tue, Aug 3, 2010 »
Code: [Select]
I would like to report a possible error. I know that it's not completely finished, but perhaps a mention of a missing function would be a little nice. However, when you get to here:

[code]var floor:B2FlxTileblock = new B2FlxTileblock(0, 400, 640, 80, _world);
floor.createBody();
floor.loadGraphic(ImgCube);
 
add(floor);

I have two errors on both the tile blocks. They are:

Code: [Select]
Error: Type was not found or was not a compile-time constant: B2FlxTileblock.Refers to the first mention.

[codeError: Call to a possibly undefined method B2FlxTileblock.[/code]
Refers to the second mention.

I'm looking at the source provided to fill in some holes. But, what am I doing wrong now?

(edit:I only juu-uust realized how old this thread was. I thought it was current, I need to look at dates more often, sigh...)
« Last Edit: Tue, Aug 3, 2010 by xhunterko »
Now on twitter: http://twitter.com/xhunterko I made a game that's in alpha you can buy here: http://xhunterko.itch.io/wave-miner-alpha

rolandinho

  • Member
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
    • My Portfolio
Re: Using Box2D in flixel [Tutorial]
« Reply #11 on: Sat, Oct 16, 2010 »
Is there a way to combine box2d width Flxtilemap and not FlxTileblock???