box2d

C++ meaning |= and &=

北城余情 提交于 2019-12-08 10:45:46
问题 I have a part of code that contains the following functions: void Keyboard(int key) { switch (key) { case GLFW_KEY_A: m_controlState |= TDC_LEFT; break; case GLFW_KEY_D: m_controlState |= TDC_RIGHT; break; case GLFW_KEY_W: m_controlState |= TDC_UP; break; case GLFW_KEY_S: m_controlState |= TDC_DOWN; break; default: Test::Keyboard(key); } } void KeyboardUp( int key) { switch (key) { case GLFW_KEY_A: m_controlState &= ~TDC_LEFT; break; case GLFW_KEY_D: m_controlState &= ~TDC_RIGHT; break; case

creating Physic body in cocos2d

坚强是说给别人听的谎言 提交于 2019-12-08 09:09:17
问题 I am creating the physical body in box2d as below , this si my code b2BodyDef carBodyDef; carBodyDef.position.Set(x/PTM_RATIO,y/PTM_RATIO); carBodyDef.type=b2_dynamicBody; b2Body* carBody=physicsWorld->CreateBody(&carBodyDef); b2CircleShape carShape; carShape.m_radius=rad/40.0f; b2FixtureDef carFixture; carFixture.shape=&carShape; carFixture.density = 1.0f; carFixture.friction = 0.0f; carBody->CreateFixture(&carFixture); return carBody ; When am running the app, its getting crash , with the

Cocos2dx Box2D - b2body GetUserData always returns null

我的未来我决定 提交于 2019-12-08 09:09:06
问题 am having one car and one bike object. at the time of collison detction. i need to get which(Car or bike) is colliding with wall. for that am using body->getuserdata . but it always returns null. am confuse d that why am getting null. were am wrong? i refer this link but same as i did. not useful. Code for car:- sprintf(temp,CAR_BODY_CAR_PLIST); m_Texture[2] = new TextureObject(temp,spritesheet1,1,true,kTexture2DPixelFormat_Default,2); // add cart // b2BodyDef bodyDef; b2FixtureDef fixtureDef

How do I make a Box2D wrap around world?

妖精的绣舞 提交于 2019-12-08 06:29:57
问题 I want to make a wrap around game effect where an object would go off the screen from the x-axis one side and reappear in a new y-axis position on the other side of the screen. The width is 250 pixels, so basically it would pass (0, y1) and would reappear at (300, y2). a.applyForceToCenter(aMovement, true); a.applyTorque(3000, true); FixtureDef fDef = new FixtureDef(); BodyDef ballD = new BodyDef(); ballD.type = BodyType.DynamicBody; //random location for asteroid int aLoc = (int) (aLocation

Cocos2d-iPhone with Box2D: CCPhysicsSprite EXC_BAD_ACCESS

不打扰是莪最后的温柔 提交于 2019-12-08 06:14:52
问题 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];

How to use Box 2 D on google colab

纵然是瞬间 提交于 2019-12-08 05:40:12
问题 I am currently trying to optimize OpenAIGym's BipedalWalker with neat. In order to use Bipedalwalker, it is necessary to install Box 2 D, but a problem arises. In order to install Box 2 d on colab, we did the following first. !apt-get install python-box2d > /dev/null !pip install gym[Box_2D] import gym env = gym.make("BipedalWalker-v2") However, this caused the following error /usr/local/lib/python3.6/dist-packages/gym/envs/box2d/lunar_lander.py in <module>() 2 import numpy as np 3 ----> 4

Deleting and creating body in libGDX

妖精的绣舞 提交于 2019-12-08 05:34:16
问题 I have a problem with deleting/creating bodies in libGDX (box2d). I get a fatal error. Log: http://pastebin.com/fXWXpe8N I try to destroy bodies after collision. ~90% bodies are deleted good, without errors and crashes. But sometimes it happens. How can I fix this error? I have no idea. Contact: private void bulletGround(Contact contact) { Body bodyA = null; Body bodyB = null; if(contact.getFixtureA() != null && contact.getFixtureA().getUserData() != null && contact.getFixtureA().getUserData(

Collision Detection with Ceramic Tile Engine & Box 2D

隐身守侯 提交于 2019-12-08 05:19:14
问题 Follow up of this question, Storyboard with Ceramic Tile Engine, and with Collision Detection is still a mystery. Here is the code: -- hide status bar display.setStatusBar(display.HiddenStatusBar) local storyboard = require("storyboard") --Set up the physics world local physics = require("physics") physics.start() physics.setGravity(0, 0) physics.setDrawMode('hybrid') local scene = storyboard.newScene() local widget = require("widget") -- Add Hero to Physics local hero = display.newImage(

In libgdx, how do I add friction to a box2d Body object?

不羁岁月 提交于 2019-12-08 01:54:51
问题 I'm having an absolute blast with libgdx, love using it. However, I am a newbie with box2d, so I was hoping someone smarter than me could help me out. I have a simple test screen, where a bunch of static square tiles make up a floor, and a dynamic body (a circle) bounces around. What I'm trying to do is to increase the friction of the floor so the ball doesn't roll as much. Like the floor was grass instead of wood. I found a couple of things online, but neither seem to work. The most

Box2D - Can't destroy multiple fixtures

老子叫甜甜 提交于 2019-12-07 21:09:32
问题 I'm using box2d along with libgdx on a project I'm working on. I'm having a slight problem destroying a body/the fixtures of a body. Essentially, I want to completely destroy the body, which I do by destroying the fixtures of said body. Everything works perfectly fine with a body with one fixture, but when I use two fixtures, only one fixture get's destroyed, leaving the body intact with the other fixture. Here's two pictures to demonstrate what I mean: With both fixtures: With only one