box2d

LibGDX/Box2D UnsatisfiedLinkError

假如想象 提交于 2019-12-10 11:19:53
问题 I'm using the EXACT same code as used in this tutorial but for some reason I get an error while trying to run the project. The default project for LibGDX worked fine. Error: Exception in thread "main" java.lang.UnsatisfiedLinkError: com.badlogic.gdx.physics.box2d.World.newWorld(FFZ)J at com.badlogic.gdx.physics.box2d.World.newWorld(Native Method) at com.badlogic.gdx.physics.box2d.World.<init>(World.java:222) at net.ocps.tchs.permarun.PermaRun.<init>(PermaRun.java:19) at net.ocps.tchs.permarun

Box2D - b2body GetUserData always returns null

五迷三道 提交于 2019-12-10 10:56:30
问题 I am trying to adjust the position and rotation of a sprite based on that of a b2body in box2d. After I have created the body im setting the userData property to that of my body object that holds the sprite and position etc. The problem is that in the tick method b->GetUserData never retrieves the object I put in there. Can you see anything wrong with the following? Here is my add player method: -(void) addPlayerShip { CCSpriteSheet *sheet = [CCSpriteSheet spriteSheetWithFile:@"PlayerShip.png

Does Box2D Physics rely on the framerate?

末鹿安然 提交于 2019-12-10 10:48:03
问题 I am making a 2D sidescroller game for Android and am thinking of using Box2D for the physics. I would like to know if when using Box2D, if the framerate of the device drops from 60 fps (Android's cap) to, for example, 30 fps will all the physics slow down with it? To elaborate, I'm going to be using real-time online multiplayer and so the framerate cannot be relied upon as a constant. So if one of the devices in the multiplayer game is running at 60 fps and another is at 30 fps and an object

IOS Box2D - body follows a specific path based on an array of points with fluctuating speed

社会主义新天地 提交于 2019-12-10 09:57:19
问题 i have a question about a body, which follows a specific path. First of all here the method to move the body to a target point: const float destinationControl = 0.3f; b2Vec2 targetPosition = path[counter]; b2Vec2 missilePosition = _physicalBody->GetPosition(); b2Vec2 diff = targetPosition - missilePosition; float dist = diff.Length(); if (dist > 0) { if(dist < destinationControl){ ++counter; return; } // compute the aiming direction b2Vec2 direction = b2Vec2(diff.x / dist, diff.y / dist); //

Cocos2d Box2D之动态刚体

£可爱£侵袭症+ 提交于 2019-12-10 03:22:01
| 版权声明:本文为博主原创文章,未经博主允许不得转载。 b2_dynamicBody 动态物体可以进行全模拟。用户可以用手手动移动动态刚体,也可以由动态刚体自己受力而自运动。动态物体可以和任何物体发生碰撞,拥有有限的非零质量。当设置动态物体的质量为零,那么动态刚体它会自动设置一个1千克质量的物体,而不会质量为0,在Box2D中物体总是刚体。动态Body也就是在物理世界中受力的运动的物体。 add BodyDef set bodyDef gravity set Linear Velocity *. 如果需要横向移动的话,只需要将b2Vec2(x,y)中的x!=0即可 来源: https://www.cnblogs.com/geore/p/5799829.html

How to subscribe self on the event of Device Orientation(not interface orientation)?

那年仲夏 提交于 2019-12-10 01:10:25
问题 in my app i want to call some method in CCScene myscene in the case of device rotation(orientation change).I disabled the autorotation(because i want it not to happen). The issue is: i want to change gravity in the scene depending on my device orientation. My code : -(void) onEnter { [super onEnter]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notification_OrientationWillChange:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil]; [

Moving Box2d Bodies Like CCSprite Objects

被刻印的时光 ゝ 提交于 2019-12-09 13:00:06
问题 In cocos2d, you can ease in CCSprites and move them around in all kinds of ways. Most importantly - they can have easing in/out. For most games this is desirable for smooth movement etc. id action = [CCMoveTo actionWithDuration:dur position:pos]; move = [CCEaseInOut actionWithAction:action rate:2]; [self runAction: move]; When moving a box2d body, the sprite attached to it is updated after the box2d step(). Moving the sprite and then updating the body is not an option here, as it entirely

Calculate correct impluse or force to move a Box2D body to a specific position - Box2D

被刻印的时光 ゝ 提交于 2019-12-09 01:51:04
问题 i have a question about moving a Box2D body to a specific position without using this for example. body->SetTransform(targetVector,body->GetAngle()) I have some code which works for applyForce (here): const float destinationControl = 0.3f; b2Vec2 missilePosition = _physicalBody->GetPosition(); b2Vec2 diff = targetPosition - missilePosition; float dist = diff.Length(); if (dist > 0) { // compute the aiming direction b2Vec2 direction = b2Vec2(diff.x / dist, diff.y / dist); // get the current

Cocos2d-iPhone with Box2D: CCPhysicsSprite EXC_BAD_ACCESS

断了今生、忘了曾经 提交于 2019-12-08 21:40:33
I just recently started messing with cocos2d's Box2D integration, while most of the process has been simple and straight forward, I keep running into a EXC_BAD_ACCESS error when using a CCPhysicsSprite (CCSprite subclass that integrates a b2body with the sprite). The code I'm using is: - (void)spawnBallAtPoint:(CGPoint)point { count++; CCPhysicsSprite *sprite = [CCPhysicsSprite spriteWithFile:@"ball.png" rect:CGRectMake(0, 0, 52, 52)]; sprite.position = point; [self addChild:sprite]; b2BodyDef bodyDef; bodyDef.type = b2_dynamicBody; bodyDef.position.Set(point.x / PTM_RATIO, point.y / PTM_RATIO

libgdx world to screen pos and factors

怎甘沉沦 提交于 2019-12-08 13:02:03
问题 I want to draw a texture on a body, which is a box. How do I convert the coordinates of the body to screen coordinates? I know that the other way around is with camera.unproject(pos), is it similar to this? I see a lot of people using constants such as WORLD_TO_SCREEN = 32, but I currently don't have that in my game. Is that a problem, and how can I implement it now? Because it seems like people that are using these factors can convert world to screen positions easily. I currently have a