I have drawn a line on sprite representing the string of a bow. I want to stretch it with finger touch input, using onTouch
. I have added a Physics body but I don't understand how to stretch the line.
Here is the code I use:
protected Scene onCreateScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
mScene = new Scene();
mScene.setBackground(new Background(0.3f, 0.8f, 0.9f));
float centerX = CAMERA_WIDTH/2;
float centerY = CAMERA_HEIGHT/2;
Sprite sprite = new Sprite(centerX,centerY,this.regionBow, this.getVertexBufferObjectManager());
mScene.attachChild(sprite);
PhysicsWorld physicsWorld = new PhysicsWorld(new Vector2(0, 300), false);
Line line = new Line(99, 10, 99, 240, 4, getVertexBufferObjectManager());
line.setColor(0f,0f,0f);
FixtureDef lineFixtureDef = PhysicsFactory.createFixtureDef(1, 4f, 0.5f);
Body body = PhysicsFactory.createLineBody(physicsWorld, line, lineFixtureDef);
mScene.getLastChild().attachChild(line);
PhysicsConnector physicsConnector = new PhysicsConnector(sprite, body, true, true);
physicsWorld.registerPhysicsConnector(physicsConnector);
mScene.setOnAreaTouchListener(new IOnAreaTouchListener() {
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent, ITouchArea pTouchArea, float pTouchAreaLocalX, float pTouchAreaLocalY) {
return false;
}
});
return this.mScene;
}