box2d

How to make two way platform box2d body?

妖精的绣舞 提交于 2019-12-13 16:26:18
问题 I have created platform using box2d. I want box2d body detect and not detect dynamically. Box2d shapes will do the followings Detect collision on some condition Not detect collision on some condition Both condition will work on different condition in same box2d object. Any idea would help a lot. Thanks in advance. 回答1: There are several ways to control what happens when a collision occurs in Box2d. The first thing to do is read this article and decide on what way you want to control it. That

how do I override a static variable of a class

放肆的年华 提交于 2019-12-13 09:57:21
问题 I'm using a library it has a public static float variable I want to know how to override it I guess that's not going to happen? //Settings.java package org.jbox2d.common; public class Settings { public static float velocityThreashold = 1.0f; } //MyClass.class package org.jbox2d.common; import com.otherlibrary public class MyClass { } Thanks 回答1: The velocityThreashold variable in your example is not final, nor is it an instance variable and therefore cannot technically be overridden. What you

ApplyLinearImpulse doesnt work when called within UIPanGestureRecognizer function

我与影子孤独终老i 提交于 2019-12-13 06:29:59
问题 I am using Box2d and Cocos2d to develop an iPhone game. I have a ball in the center of the screen with a simple boundary created using fixtures etc. What I want to do is add the functionality so that a user can "swipe" the ball to apply force and basically flick it across the screen. I am using the following code to achieve this: b2Vec2 force = b2Vec2(30, 30); _body->ApplyLinearImpulse(force, _ballBodyDef->position); If I apply a linear impulse during the init function the ball fires off in

make a body which moves continuously

懵懂的女人 提交于 2019-12-13 06:12:53
问题 I am working with Box-2d & AndEngine . I have dynamic body lets say a Plane . I want to moves this continuously with a given velocity. So, I set a linear Velocity to it. I have screen boundary(ground,roof,left & Right Wall) as well. Those are static body. When my plane collides with boundaries one or two times, it's becomes stopped. I apply no gravity to plane. Why plane stopped though it has fixed velocity? Problem : How I move the plane with continuous speed as well as corresponding

Libgdx NESTED ShapeRenderer not drawing lines

柔情痞子 提交于 2019-12-13 05:48:47
问题 In the code below I retrieve an arraylist of vertices (I've debugged and they are in fact there) and then attempt to render them in this nest loop arrangement which is hosted in the render method. For some reason, the ShapeRenderer cannot connect all the lines if this is nested? Can someone tell me what I'm doing wrong? Nothing is being drawn to the screen; I get no errors. shapeRenderer.setProjectionMatrix(camera.combined); shapeRenderer.begin(ShapeType.Line); for(int i = 0;i<tmpBodies.size

When to use CC_CONTENT_SCALE_FACTOR()?

这一生的挚爱 提交于 2019-12-13 04:44:24
问题 I am a bit confused on when to use CC_CONTENT_SCALE_FACTOR() in my app. I use Box2D for collision detection, and I make a b2Body of vertices. Now should I divide each point only by the PTM_Ratio or by the PTM_Ratio multiplied by CC_CONTENT_SCALE_FACTOR()? Should I be using CC_CONTENT_SCALE_FACTOR() anywhere in my app if I am not dealing with pixels? Should I only use CC_CONTENT_SCALE_FACTOR() for GLESDebugDraw like this? _debugDraw = new GLESDebugDraw( ptmRatio * CC_CONTENT_SCALE_FACTOR()); ?

CCSprite is moved when using CCScaleTo or CCScaleBy

て烟熏妆下的殇ゞ 提交于 2019-12-13 04:26:38
问题 I almost have read everything about Anchor Point and scaling. I still have no idea what is going on with a sprites position when i scale it. The scenario is this: When i tap on screen, sprite's width will decrease about %50 and height will increase about same scale. Then it will get back to its normal scale. id scaleUpAction = [CCEaseInOut actionWithAction:[CCScaleTo actionWithDuration:.35 scaleX:0.5 scaleY:1.5] rate:1.0]; id scaleDownAction = [CCEaseInOut actionWithAction:[CCScaleTo

Box2D via libGDX: How to create one MouseJoint per body for separate Android touches?

落爺英雄遲暮 提交于 2019-12-13 03:59:05
问题 What's up everyone, Thanks for your time. I am making a Pong clone, and I want to restrict Box2D to two MouseJoints maximum; one MouseJoint maximum per paddle. The MouseJoints should be created only if one of the user's two touches lands within either of the two paddle's boundaries. I am getting a weird result with my code. If my first touch lands within the left paddle and my second touch lands outside of either paddle, a second MouseJoint is created on the left paddle (see attached image).

Box2D and wrapping worlds

对着背影说爱祢 提交于 2019-12-13 03:17:22
问题 I really stuck at implementing wrapping world with Box2D. I want to create game object appearing from left when it hides to the right and vice versa and the same for top-down. My idea is to use object wich contains NSArray with 9 elements for superposition matrix (it's a quantum state when object exists at different locations at the same time, isn't it?). Every element must contain the body. It covers all situations and has a more clear logic for me. For example, if my object doesn't touch

Game Objects setup in cocos2d + box2d

时间秒杀一切 提交于 2019-12-13 03:04:58
问题 I am having a design issue, this may be due to the fact that i don't fully understand cocos2d and box2d yet. I want to create game objects that have a CCSprite(image data) and a b2Body(physics), Would i be right to make an encapsulating object that contains both? if i did this this would enable me to make changes to the CCSprite OR as i have seen in the example code the b2Body has a userData variable which the sprite is set as. Then with this method i would only need to have a single pointer