Collision filtering in libgdx using Liquidfun - libgdx

I successfully implemented liquidfun extension in my libgdx/box2d project, but the particles that are created in the box2d world doesn't seem to collide with anything at all when used in my project. The test code given with the setup works good in the way that it collides with the rigid bodies.
I actually want to know any way that collision filtering can be done between the particles and rigid bodies here. Apparently categorybits/maskbits do not work here. Please Help!

Related

Using Physics Editor and using it's .plist Cocos2d-x V3 for better collision detection

I was working on a cocos2d-x project. Its a simple game. Everything is working right apart from collision. Though, It is working but collision is not very realistic. I browsed and discovered something called - Physics Editor. I read tutorials from - http://www.codeandweb.com. It generates a .plist of your sprite. I'm making game for android in c++.
Now the problem -
How to use that .plist with cocos2d-x V3.8. Is it a good idea to make collision detection better this way?
I want to start with box2d and chipmunk but there are no good and new tutorials. In case you have anything, Feel free to suggest. Thanks is advance !
Actually Physics Editor itself provides special C++ class for loading its plist and creating PhysicsObjects from it.
You can easily get it on github: https://github.com/CodeAndWeb/PhysicsEditor-Loaders/tree/master/cocos2d-x

Box2D world.step() delay at first 2 runs

I'm programming a game using ActionScript 3.0 and included Box2D classes for its physics. It's a maze/labyrinth game having a lot of walls and a ball inside.
In my main fla when I call the maze.create(), the maze is created (visually and physically) and it will dispatch an event so I know when it's done working and then I call my frameHandler which calls another function from my maze class every frame and the big delay accrues exactly at world.step() in it. BUT THE THING IS that it lags only the first two times this function runs!!!
The reason I notice this lag, is that I've got another object starting to move according to mouse position in the same frame handler.
The reason I'm sure the world.step() is causing it, is that everything works fine when I dont call it.
I've seen many codes using Box2d, some had more objects than i have and I know that I've created my b2World and all the objects correctly, similar to all the Box2d tutorials and stuff BUT THEY DONT LAG AT ALL. Its just mine lagging and all!!
Do you have any Idea or similar experience?
Do you have any suggestion in general how to deal with heavy functions?
PLEEEEASE +.-
A maze will have a lot of fixtures in close proximity making a very dense dynamic tree (the method Box2D uses to optimize collision checks). There is unlikely to be any way around this. Perhaps you could just call Step a few times after adding the static walls, but before you add the dynamic ball bodies, and consider it part of the loading process. At least the lagging movements will not be visible to the player.

hitTestObject() collide somehow not working how it should

Or that's what I think, at least.
I just began with AS3 and I'm trying to do a little game where one ball moves on its own and the other one is handled by the player. So far, so good. That works.
What isn't working is hitTestObject(); it just returns true when it's like 2 cm from the other object. Here's a picture so you can see: http://dl.dropbox.com/u/37057843/coll2.jpg
I've read that hitTestObject just creats a rectangle around the objects and then tests for collisions on those rectangles, is it because of that?
If you need any piece of code I'll deliver. I know there are some other opensource libraries/engines like Box2D to solve this in a better way, but I don't want to jump to engines directly.
Thanks for reading!
Yes, hitTestObject will use the clips bounding box.
Check out this link, it has a lot of great information as well as a class that will do what you're looking for
http://sierakowski.eu/list-of-tips/39-collision-detection-methods-hittest-and-hittestobject-alternatives.html
Direct link to the package
http://code.google.com/p/collisiondetectionkit/

Hit testing for a maze

I am making a maze game and i have the edge of the maze as a movieclip. I'm trying to test if the player hit tests the maze to make him stop using this code.
If(player.hitTestObject(Maze))
{
function()
}
But wether or not It's actually touching the maze (it's in the empty space on the inside) it always registers as touching. Is there any way to fix this?
You won't have to use any physics api. They are too heavy and complex and your task is simple. Try replacing your hitTest method for hitTestPoint
if(Maze.hitTestPoint(player.x,player.y))
{
function()
}
Cheers!
This is what you're looking for:
http://www.mikechambers.com/blog/2009/06/24/using-bitmapdata-hittest-for-collision-detection/
The reason why hitTest always says true, is that it only checks to see if the bounding boxes for the two objects touch each other. More nfo on what that means can probably be found in the link above. What is in the link above, is an explanation of how to do pixel-perfect hit tests in flash. :) Also if you're doing a game using collision like this and/or any kind of physics, you may be interest in this tutorial:
http://gotoandlearn.com/play.php?id=135
It's a video about a world construction kit for Box2D, probably the most popular physics library for flash.

Flash CS4 / AS3 symbol within symbols

I'm trying to create a multi-level dungeon adventure in Flash CS4. The layout is an instance created of a symbol called Level, within the symbol are multiple wall subsymbols (wall), instances of Wall. There is a collision routine to stop the player walking through the walls, called from Wall.As.
Level is drawn about the centre point (0,0).
When I create an instance on the stage of Level (level), the collision tester is using the xy coordinates for the walls drawn about 0,0, not the "real" xy where it's appearing on the stage.
So what I need to know, is how to "update" the xy for each wall subsymbol with the live stage information, overriding the XYs drawn in the parent. It has to be updated unfortunately (I can't keep it static), as the levels are big so have to scroll.
Thanks for your advice.
With all due respect forget your approach, you're reinventing the wheel for nothing and probably to end up getting worse performance. What you need is pixel-perfect collision detection and probably including basic physics so already we're talking a huge amount of work. If you want to build levels in a design way for a game, use this, it'll blow your mind how awesome/easy/cool this is:
http://www.gotoandlearn.com/play.php?id=135
Its always a guess when trying to answer questions like this, as there are a lot of unknowns. That being said, in programming, there are always more than a few ways to solve a problem. Examine your collision detection routine - if you worked with hitTestPoint, and the point that was being tested (mouseX,Y or your main actor) with localToGlobal, you likely wouldn't need to test for the x,y variables of your collision objects. Read up on those two subjects and this question might be rendered moot.
At any rate, you could update relative coordinates in your Wall.as instance by leveraging globlaToLocal:
public function get curLoc():Point
{
return globalToLocal(new Point(this.x, this.y));
}
and retrieve them from your parent class as a point you can then test against:
trace(_wall.curLoc);
Hope that helps
I suppose you could accomplish what you're trying to do by manipulating the transform property of the wall symbols, but honestly I would concur with Ascension Systems and just abandon your collision testing routine for something different.
You may not need to go all out with a physics engine for your game, in which case just use hitTestObject to do the collision detection.