List of usage examples for com.badlogic.gdx.math MathUtils radDeg
float radDeg
To view the source code for com.badlogic.gdx.math MathUtils radDeg.
Click Source Link
From source file:com.agateau.pixelwheels.bonus.Missile.java
License:Open Source License
private void findTarget() { World world = mGameWorld.getBox2DWorld(); mTarget = mRacerFinder.find(world, mBody.getWorldCenter(), mBody.getAngle() * MathUtils.radDeg); }
From source file:com.agateau.pixelwheels.bonus.Missile.java
License:Open Source License
private void drawReactorFire(Batch batch) { TextureRegion region = mAssets.turboFlame.getKeyFrame(mTime, true); Vector2 center = mBody.getPosition(); float angle = mBody.getAngle(); float w = Constants.UNIT_FOR_PIXEL * region.getRegionWidth(); float h = Constants.UNIT_FOR_PIXEL * region.getRegionHeight(); float refH = Constants.UNIT_FOR_PIXEL * -WIDTH / 2; float x = center.x + refH * MathUtils.cos(angle); float y = center.y + refH * MathUtils.sin(angle); batch.draw(region, x - w / 2, y - h, // pos w / 2, h, // origin w, h, // size 1, 1, // scale angle * MathUtils.radDeg - 90); }
From source file:com.agateau.pixelwheels.racescreen.PieButton.java
License:Open Source License
@Override public Actor hit(float x, float y, boolean touchable) { // Let the base implementation perform AABB collision detection Actor result = super.hit(x, y, touchable); if (result == null) { return null; }/*from w ww . j a v a 2 s . c om*/ // Check if we are outside the radius x -= getOriginX(); y -= getOriginY(); float radius = mRadius * getHud().getZoom(); if (x * x + y * y > radius * radius) { return null; } // Now check if we hit the right sector float angle = MathUtils.atan2(y, x) * MathUtils.radDeg; if (mFrom <= angle && angle <= mTo) { return this; } else { return null; } }
From source file:com.agateau.pixelwheels.utils.BodyRegionDrawer.java
License:Open Source License
public void draw(Body body, TextureRegion region) { Vector2 center = body.getPosition(); float angle = body.getAngle(); float x = center.x + mOffsetX * MathUtils.cos(angle) - mOffsetY * MathUtils.sin(angle); float y = center.y + mOffsetX * MathUtils.sin(angle) + mOffsetY * MathUtils.cos(angle); float w = Constants.UNIT_FOR_PIXEL * region.getRegionWidth(); float h = Constants.UNIT_FOR_PIXEL * region.getRegionHeight(); mBatch.draw(region, x - w / 2, y - h / 2, // pos w / 2, h / 2, // origin w, h, // size mScale, mScale, angle * MathUtils.radDeg); }
From source file:com.pastew.autogearbox.handlers.Box2DSprite.java
License:Apache License
/** Used internally. Draws this {@code Box2DSprite} in classic sprite coordinate system fashion with the given Box2D coordinates (combined with its own position, size and rotation).<br> * If {@link #useOriginX useOriginX/Y} is enabled, the {@link #originX origin} will be used instead of calculating an appropriate one for the given Box2D coordinates.<br> * If {@link #adjustWidth adjustWidth/Height} is disabled, the size of the drawing area of the sprite will be {@link #width} * {@link #height} instead of the given size.<br> * The drawing position of the sprite is always the bottom left of the body or fixture. * @param box2dX the x coordinate (center) of the body or fixture * @param box2dY the y coordinate (center) of the body or fixture * @param box2dWidth the width of the body or fixture * @param box2dHeight the height of the body or fixture * @param box2dRotation the rotation of the body or fixture */ public void draw(Batch batch, float box2dX, float box2dY, float box2dWidth, float box2dHeight, float box2dRotation) { batch.setColor(getColor());//from w ww. j av a 2 s. c o m batch.draw(this, box2dX - box2dWidth / 2 + getX(), box2dY - box2dHeight / 2 + getY(), useOriginX ? getOriginX() : box2dWidth / 2, useOriginY ? getOriginY() : box2dHeight / 2, adjustWidth ? box2dWidth : getWidth(), adjustHeight ? box2dHeight : getHeight(), getScaleX(), getScaleY(), box2dRotation * MathUtils.radDeg + getRotation()); }
From source file:com.turbogerm.helljump.game.enemies.EvilTwinEnemy.java
License:Open Source License
public EvilTwinEnemy(EnemyData enemyData, int startStep, AssetManager assetManager) { super(enemyData, ResourceNames.ENEMY_EVIL_TWIN_IMAGE_NAME, startStep, assetManager); Vector2 initialPosition = enemyData.getPosition(startStep); float speed = Float.parseFloat(enemyData.getProperty(EnemyData.SPEED_PROPERTY)); float[] ranges = getRanges(enemyData.getProperty(EnemyData.RANGES_PROPERTY)); int numCurves = ranges.length; mAngleSpeeds = new float[numCurves]; mRadiuses = new float[numCurves]; mRotationCenters = new Vector2[numCurves]; mPosition = new Vector2(); mCenterOffset = new Vector2(mSprite.getWidth() / 2.0f, mSprite.getHeight() / 2.0f); float rotationCenterY = initialPosition.y + mCenterOffset.y; for (int i = 0; i < numCurves; i++) { mRadiuses[i] = ranges[i] / 2.0f; mAngleSpeeds[i] = speed / mRadiuses[i] * MathUtils.radDeg; float rotationCenterX = i == 0 ? initialPosition.x + mCenterOffset.x + mRadiuses[i] : mRotationCenters[i - 1].x + mRadiuses[i - 1] + mRadiuses[i]; mRotationCenters[i] = new Vector2(rotationCenterX, rotationCenterY); }//from www .j a v a2 s .c o m mAngleParameter = 0.0f; mHalfMaxAngleParameter = numCurves * 180.0f; mMaxAngleParameter = mHalfMaxAngleParameter * 2.0f; float x = mSprite.getX() + COLLISION_PADDING; float y = mSprite.getY() + COLLISION_PADDING; float width = mSprite.getWidth() - 2.0f * COLLISION_PADDING; float height = mSprite.getHeight() - 2.0f * COLLISION_PADDING; mCollisionRect = new Rectangle(x, y, width, height); }
From source file:com.turbogerm.helljump.game.enemies.KnightEnemy.java
License:Open Source License
public KnightEnemy(EnemyData enemyData, int startStep, AssetManager assetManager) { super(enemyData, ResourceNames.ENEMY_KNIGHT_IMAGE_NAME, startStep, assetManager); float range = GameArea.GAME_AREA_WIDTH - mSprite.getWidth(); mRadius = range / 4.0f;/*w w w .j a v a 2s. c om*/ mAngleSpeed = SPEED / mRadius * MathUtils.radDeg; mAngleParameter = 0.0f; mPosition = new Vector2(); mCenterOffset = new Vector2(mSprite.getWidth() / 2.0f, mSprite.getHeight() / 2.0f); mRotationCenters = new Vector2[2]; mRotationCenters[0] = new Vector2(mCenterOffset.x + mRadius, mSprite.getY() + mCenterOffset.y); mRotationCenters[1] = new Vector2(mRotationCenters[0].x + mRadius * 2.0f, mRotationCenters[0].y); float x = mSprite.getX() + COLLISION_PADDING; float y = mSprite.getY() + COLLISION_PADDING; float width = mSprite.getWidth() - 2.0f * COLLISION_PADDING; float height = mSprite.getHeight() - 2.0f * COLLISION_PADDING; mCollisionRect = new Rectangle(x, y, width, height); }
From source file:com.turbogerm.helljump.game.platforms.movement.CircularPlatformMovement.java
License:Open Source License
public CircularPlatformMovement(PlatformMovementData movementData, Vector2 initialPosition, AssetManager assetManager) {//from w w w .j ava2 s . co m super(initialPosition, ResourceNames.PLATFORM_ENGINE_NORMAL_IMAGE_NAME, ResourceNames.PARTICLE_ENGINE_NORMAL, assetManager); mRadius = Float.parseFloat(movementData.getProperty(PlatformMovementData.RADIUS_PROPERTY)); mSpeed = Float.parseFloat(movementData.getProperty(PlatformMovementData.SPEED_PROPERTY)); mIsCcw = PlatformMovementData.DIRECTION_CCW_PROPERTY_VALUE .equals(movementData.getProperty(PlatformMovementData.DIRECTION_PROPERTY)); mAngleSpeed = mSpeed / mRadius * MathUtils.radDeg; mAngle = 0.0f; mRotationCenter = new Vector2(initialPosition.x + PLATFORM_CENTER_OFFSET.x + mRadius, initialPosition.y + PLATFORM_CENTER_OFFSET.y); float initialDegrees = Float .parseFloat(movementData.getProperty(PlatformMovementData.INITIAL_DEGREES_PROPERTY)); changePosition(initialDegrees); }
From source file:spine.Bone.java
License:Open Source License
public float getWorldRotationX() { return (float) Math.atan2(c, a) * MathUtils.radDeg; }
From source file:spine.Bone.java
License:Open Source License
public float getWorldRotationY() { return (float) Math.atan2(d, b) * MathUtils.radDeg; }