本文整理汇总了Java中org.robovm.apple.coregraphics.CGPoint类的典型用法代码示例。如果您正苦于以下问题:Java CGPoint类的具体用法?Java CGPoint怎么用?Java CGPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CGPoint类属于org.robovm.apple.coregraphics包,在下文中一共展示了CGPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAnchorPair
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
private static AAPLGeoAnchorPair createAnchorPair(CLLocationCoordinate2D topLeft,
CLLocationCoordinate2D bottomRight,
CGSize imageSize) {
AAPLGeoAnchor topLeftAnchor = new AAPLGeoAnchor();
topLeftAnchor.latitudeLongitude = topLeft;
topLeftAnchor.pixel = new CGPoint(0, 0);
AAPLGeoAnchor bottomRightAnchor = new AAPLGeoAnchor();
bottomRightAnchor.latitudeLongitude = bottomRight;
bottomRightAnchor.pixel = new CGPoint(imageSize.getWidth(), imageSize.getHeight());
AAPLGeoAnchorPair anchorPair = new AAPLGeoAnchorPair();
anchorPair.fromAnchor = topLeftAnchor;
anchorPair.toAnchor = bottomRightAnchor;
return anchorPair;
}
示例2: getPointFromCoordinate
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
public CGPoint getPointFromCoordinate(CLLocationCoordinate2D coordinate) {
// Get the distance east & south with respect to the first anchor point
// in meters
AAPLEastSouthDistance toFix = convertPoint(fromAnchorMKPoint, new MKMapPoint(coordinate));
// Convert the east-south anchor point distance to pixels (still in
// east-south)
CGPoint pixelsXYInEastSouth = new CGPoint(toFix.east, toFix.south).apply(CGAffineTransform.createScale(
pixelsPerMeter,
pixelsPerMeter));
// Rotate the east-south distance to be relative to floorplan horizontal
// This gives us an xy distance in pixels from the anchor point.
CGPoint xy = pixelsXYInEastSouth.apply(CGAffineTransform.createRotation(radiansRotated));
// however, we need the pixels from the (0, 0) of the floorplan
// so we adjust by the position of the anchor point in the floorplan
xy.setX(xy.getX() + fromAnchorFloorplanPoint.getX());
xy.setY(xy.getY() + fromAnchorFloorplanPoint.getY());
return xy;
}
示例3: updateView
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
private void updateView(final CLLocation location) {
// We animate transition from one position to the next, this makes the
// dot move smoothly over the map
UIView.animate(0.75, new Runnable() {
@Override
public void run() {
// Call the converter to find these coordinates on our
// floorplan.
CGPoint pointOnImage = coordinateConverter.getPointFromCoordinate(location.getCoordinate());
// These coordinates need to be scaled based on how much the
// image has been scaled
CGPoint scaledPoint = new CGPoint(pointOnImage.getX() * displayScale + displayOffset.getX(),
pointOnImage.getY()
* displayScale + displayOffset.getY());
// Calculate and set the size of the radius
double radiusFrameSize = location.getHorizontalAccuracy() * coordinateConverter.getPixelsPerMeter() * 2;
radiusView.setFrame(new CGRect(0, 0, radiusFrameSize, radiusFrameSize));
// Move the pin and radius to the user's location
pinView.setCenter(scaledPoint);
radiusView.setCenter(scaledPoint);
}
});
}
示例4: recenterIfNecessary
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
/** Recenter content periodically to achieve impression of infinite scrolling. */
private void recenterIfNecessary () {
CGPoint currentOffset = getContentOffset();
double contentWidth = getContentSize().getWidth();
double centerOffsetX = (contentWidth - getBounds().getSize().getWidth()) / 2.0;
double distanceFromCenter = Math.abs(currentOffset.getX() - centerOffsetX);
if (distanceFromCenter > (contentWidth / 4.0)) {
setContentOffset(currentOffset.setX(centerOffsetX));
// move content by the same amount so it appears to stay still
for (UILabel label : visibleLabels) {
CGPoint center = labelContainerView.convertPointToView(label.getCenter(), this);
center.setX(center.getX() + centerOffsetX - currentOffset.getX());
label.setCenter(convertPointToView(center, labelContainerView));
}
}
}
示例5: dispatchTouchEndEvent
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
/**
* Checks to see which view, or views, the point is in and then calls a
* method to perform the closing animation, which is to return the piece to
* its original size, as if it is being put down by the user.
*/
private void dispatchTouchEndEvent(UIView view, CGPoint position) {
// Check to see which view, or views, the point is in and then animate
// to that position.
if (firstPieceView.getFrame().contains(position)) {
animateView(firstPieceView, position);
}
if (secondPieceView.getFrame().contains(position)) {
animateView(secondPieceView, position);
}
if (thirdPieceView.getFrame().contains(position)) {
animateView(thirdPieceView, position);
}
// If one piece obscures another, display a message so the user can move
// the pieces apart.
if (firstPieceView.getCenter().equalsTo(secondPieceView.getCenter()) ||
firstPieceView.getCenter().equalsTo(thirdPieceView.getCenter()) ||
secondPieceView.getCenter().equalsTo(thirdPieceView.getCenter())) {
touchInstructionsText.setText("Double tap the background to move the pieces apart.");
piecesOnTop = true;
} else {
piecesOnTop = false;
}
}
示例6: panPiece
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
/**
* Shift the piece's center by the pan amount. Reset the gesture
* recognizer's translation to {0, 0} after applying so the next callback is
* a delta from the current position.
*/
@IBAction
private void panPiece(UIPanGestureRecognizer gestureRecognizer) {
UIView piece = gestureRecognizer.getView();
adjustAnchorPointForGestureRecognizer(gestureRecognizer);
if (gestureRecognizer.getState() == UIGestureRecognizerState.Began
|| gestureRecognizer.getState() == UIGestureRecognizerState.Changed) {
CGPoint translation = gestureRecognizer.getTranslation(piece.getSuperview());
piece.setCenter(new CGPoint(piece.getCenter().getX() + translation.getX(), piece.getCenter().getY()
+ translation.getY()));
gestureRecognizer.setTranslation(CGPoint.Zero(), piece.getSuperview());
}
}
示例7: updateAlpha
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
public void updateAlpha (APAMultiplayerLayeredCharacterScene scene) {
if (!fadeAlpha) {
return;
}
double closestHeroDistance = Float.MAX_VALUE;
// See if there are any heroes nearby.
CGPoint ourPosition = getPosition();
for (SKNode hero : scene.getHeroes()) {
CGPoint theirPos = hero.getPosition();
double distance = APAUtils.getDistanceBetweenPoints(ourPosition, theirPos);
if (distance < closestHeroDistance) {
closestHeroDistance = distance;
}
}
if (closestHeroDistance > OPAQUE_DISTANCE) {
// No heroes nearby.
setAlpha(1);
} else {
// Adjust the alpha based on how close the hero is.
setAlpha(0.1 + ((closestHeroDistance / OPAQUE_DISTANCE) * (closestHeroDistance / OPAQUE_DISTANCE)) * 0.9);
}
}
示例8: APABoss
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
public APABoss(CGPoint position) {
super(new SKTextureAtlas("Boss/Boss_Idle").getTexture("boss_idle_0001.png"), position);
movementSpeed = MOVEMENT_SPEED * 0.35f;
animationSpeed = 1.0 / 35.0;
setZPosition(-0.25);
setName("Boss");
attacking = false;
// Make it AWARE!
APAChaseAI intelligence = new APAChaseAI(this, null);
intelligence.setChaseRadius(CHASE_RADIUS);
intelligence.setMaxAlertRadius(CHASE_RADIUS * 4.0);
this.intelligence = intelligence;
}
示例9: moveTowards
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
public void moveTowards (CGPoint position, double timeInterval) {
CGPoint curPosition = getPosition();
double dx = position.getX() - curPosition.getX();
double dy = position.getY() - curPosition.getY();
double dt = movementSpeed * timeInterval;
double ang = APAUtils.polarAdjust(APAUtils.getRadiansBetweenPoints(position, curPosition));
setZRotation(ang);
double distRemaining = Math.hypot(dx, dy);
if (distRemaining < dt) {
setPosition(position);
} else {
setPosition(new CGPoint(curPosition.getX() - Math.sin(ang) * dt, curPosition.getY() + Math.cos(ang) * dt));
}
requestedAnimation = APAAnimationState.Walk;
}
示例10: moveInDirection
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
public void moveInDirection (CGPoint direction, double timeInterval) {
CGPoint curPosition = getPosition();
double dx = movementSpeed * direction.getX();
double dy = movementSpeed * direction.getY();
double dt = movementSpeed * timeInterval;
CGPoint targetPosition = new CGPoint(curPosition.getX() + dx, curPosition.getY() + dy);
double ang = APAUtils.polarAdjust(APAUtils.getRadiansBetweenPoints(targetPosition, curPosition));
setZRotation(ang);
double distRemaining = Math.hypot(dx, dy);
if (distRemaining < dt) {
setPosition(targetPosition);
} else {
setPosition(new CGPoint(curPosition.getX() - Math.sin(ang) * dt, curPosition.getY() + Math.cos(ang) * dt));
}
// Don't change to a walk animation if we planning an attack.
if (!attacking) {
requestedAnimation = APAAnimationState.Walk;
}
}
示例11: APACave
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
public APACave (CGPoint position) {
super(new NSArray<SKSpriteNode>((SKSpriteNode)sharedCaveBase.copy(), (SKSpriteNode)sharedCaveTop.copy()), position, 50.0);
timeUntilNextGenerate = 5.0 + Math.random() * 5.0;
for (int i = 0; i < CAVE_CAPACITY; i++) {
APAGoblin goblin = new APAGoblin(getPosition());
goblin.setCave(this);
inactiveGoblins.add(goblin);
}
movementSpeed = 0.0;
pickRandomFacing(position);
setName("GoblinCave");
// Make it AWARE!
intelligence = new APASpawnAI(this, null);
}
示例12: pickRandomFacing
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
private void pickRandomFacing (CGPoint position) {
APAMultiplayerLayeredCharacterScene scene = getCharacterScene();
// Pick best random facing from 8 test rays.
double maxDoorCanSee = 0.0;
double preferredZRotation = 0.0;
for (int i = 0; i < 8; i++) {
double testZ = Math.random() * (Math.PI * 2.0);
CGPoint pos2 = new CGPoint(-Math.sin(testZ) * 1024 + position.getX(), Math.cos(testZ) * 1024 + position.getY());
double dist = scene.getDistanceToWall(position, pos2);
if (dist > maxDoorCanSee) {
maxDoorCanSee = dist;
preferredZRotation = testZ;
}
}
setZRotation(preferredZRotation);
}
示例13: generate
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
public void generate () {
if (globalCap > 0 && globalAllocation >= globalCap) {
return;
}
APACharacter object = inactiveGoblins.last();
if (object == null) {
return;
}
double offset = COLLISION_RADIUS * 0.75;
double rot = APAUtils.polarAdjust(getVirtualZRotation());
object.setPosition(APAUtils.getPointByAddingPoints(getPosition(), new CGPoint(Math.cos(rot) * offset, Math.sin(rot)
* offset)));
APAMultiplayerLayeredCharacterScene scene = getCharacterScene();
object.addToScene(scene);
object.setZPosition(-1.0);
object.fadeIn(0.5);
inactiveGoblins.remove(object);
activeGoblins.add((APAGoblin)object);
globalAllocation++;
}
示例14: updateOffset
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
public void updateOffset () {
SKScene scene = getScene();
SKNode parent = getParent();
if (!usesParallaxEffect || parent == null) {
return;
}
CGPoint scenePos = scene.convertPointFromNode(getPosition(), parent);
// Calculate the offset directions relative to the center of the screen.
// Bias to (-0.5, 0.5) range.
double offsetX = -1.0 + (2.0 * (scenePos.getX() / scene.getSize().getWidth()));
double offsetY = -1.0 + (2.0 * (scenePos.getY() / scene.getSize().getHeight()));
double delta = parallaxOffset / getChildren().size();
int childNumber = 0;
for (SKNode node : getChildren()) {
node.setPosition(new CGPoint(offsetX * delta * childNumber, offsetY * delta * childNumber));
childNumber++;
}
}
示例15: setup
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
@Override
public void setup() {
super.setup();
// Build level and tree maps.
levelMap = APAUtils.createDataMap("map_level.png");
treeMap = APAUtils.createTreeMap("map_trees.png");
APACave.setGlobalGoblinCap(32);
buildWorld();
// Center the camera on the hero spawn point.
CGPoint startPosition = defaultSpawnPoint;
centerWorldOnPosition(startPosition);
}