/** Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up. * @param degrees the angle in degrees * @param reference center Vector2 */ public Vector2 rotateAround (Vector2 reference, float degrees) { return this.sub(reference).rotate(degrees).add(reference); }
/** Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up. * @param degrees the angle in degrees * @param reference center Vector2 */ public Vector2 rotateAround (Vector2 reference, float degrees) { return this.sub(reference).rotate(degrees).add(reference); }
public void draw (Batch batch, float parentAlpha) { // Use Stage#toScreenCoordinates, which we know is correct. toScreenCoordinates.set(testX, testY).sub(getOriginX(), getOriginY()).scl(getScaleX(), getScaleY()).rotate(getRotation()) .add(getOriginX(), getOriginY()).add(getX(), getY()); getStage().toScreenCoordinates(toScreenCoordinates, batch.getTransformMatrix()); // Do the same as toScreenCoordinates via Actor#localToParentCoordinates. localToAscendantCoordinates(null, localToParentCoordinates.set(testX, testY)); getStage().stageToScreenCoordinates(localToParentCoordinates); // System.out.println(name + " " + toScreenCoordinates + " " + localToParentCoordinates); batch.setColor(getColor()); batch.draw(region, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation()); super.draw(batch, parentAlpha); } }
rotating.rotate(93 * changeRate);
//A vector pointing up Vector2 direction = new Vector2(0, 1); //Let's rotate that by the rotation of the arm direction.rotate(rot);
/** Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up. * @param degrees the angle in degrees * @param reference center Vector2 */ public Vector2 rotateAround (Vector2 reference, float degrees) { return this.sub(reference).rotate(degrees).add(reference); }
/** * Apply force on joint, pushing the attached entity out of place. * * @param Attached Attached component of entity to push * @param rotation Direction of force * @param force strength of force (don't factor in delta). */ public void push(final Attached attached, float rotation, float force) { vTmp.set(force, 0).rotate(rotation).add(attached.slackX, attached.slackY).clamp(0f, attached.maxSlack); attached.slackX = vTmp.x; attached.slackY = vTmp.y; }
/** * Apply force on joint, pushing the attached entity out of place. * * @param attached Attached component of entity to push * @param rotation Direction of force * @param force strength of force (don't factor in delta). */ public void push(final Attached attached, float rotation, float force) { vTmp.set(force, 0).rotate(rotation).add(attached.slackX, attached.slackY).clamp(0f, attached.maxSlack); attached.slackX = vTmp.x; attached.slackY = vTmp.y; }
/** * Apply force on joint, pushing the attached entity out of place. * * @param attached Attached component of entity to push * @param rotation Direction of force * @param force strength of force (don't factor in delta). */ public void push(final Attached attached, float rotation, float force) { vTmp.set(force, 0).rotate(rotation).add(attached.slackX, attached.slackY).clamp(0f, attached.maxSlack); attached.slackX = vTmp.x; attached.slackY = vTmp.y; }
private Vector2 origin; private Vector2 distance; void ctor(){ origin = new Vector2(); distance = new Vector2(0, 100); } public void update(float Delta){ origin.set(200, 200); distance.rotate(40 * Delta); Vector2 newPos = origin.add(distance); sprite.setPosition(newPos.x - sprite.width/2, newPos.y - sprite.height/2); }