本文整理汇总了Java中org.robovm.apple.coregraphics.CGPoint类的典型用法代码示例。如果您正苦于以下问题:Java CGPoint类的具体用法?Java CGPoint怎么用?Java CGPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CGPoint类属于org.robovm.apple.coregraphics包,在下文中一共展示了CGPoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:18,代码来源:AAPLCoordinateConverter.java
示例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;
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:23,代码来源:AAPLCoordinateConverter.java
示例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);
}
});
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:27,代码来源:AAPLViewController.java
示例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));
}
}
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:19,代码来源:InfiniteScrollView.java
示例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;
}
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:30,代码来源:APLViewController.java
示例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());
}
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:21,代码来源:APLViewController.java
示例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);
}
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:26,代码来源:APATree.java
示例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;
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:18,代码来源:APABoss.java
示例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;
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:19,代码来源:APACharacter.java
示例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;
}
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:24,代码来源:APACharacter.java
示例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);
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:20,代码来源:APACave.java
示例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);
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:19,代码来源:APACave.java
示例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++;
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:27,代码来源:APACave.java
示例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++;
}
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:24,代码来源:APAParallaxSprite.java
示例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);
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:17,代码来源:APAAdventureScene.java
示例16: addSpawnPoints
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
private void addSpawnPoints() {
// Add goblin caves and set hero/boss spawn points.
for (int y = 0; y < LEVEL_MAP_SIZE; y++) {
for (int x = 0; x < LEVEL_MAP_SIZE; x++) {
CGPoint location = new CGPoint(x, y);
APADataMap spot = queryLevelMap(location);
// Get the world space point for this level map pixel.
CGPoint worldPoint = convertLevelMapPointToWorldPoint(location);
if (spot.getBossLocation() <= 200) {
levelBoss = new APABoss(worldPoint);
levelBoss.addToScene(this);
} else if (spot.getGoblinCaveLocation() >= 200) {
APACave cave = new APACave(worldPoint);
goblinCaves.add(cave);
parallaxSprites.add(cave);
cave.addToScene(this);
} else if (spot.getHeroSpawnLocation() >= 200) {
defaultSpawnPoint = worldPoint; // there's only one
}
}
}
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:25,代码来源:APAAdventureScene.java
示例17: getDistanceToWall
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
@Override
public double getDistanceToWall(CGPoint pos0, CGPoint pos1) {
CGPoint a = convertWorldPointToLevelMapPoint(pos0);
CGPoint b = convertWorldPointToLevelMapPoint(pos1);
double deltaX = b.getX() - a.getX();
double deltaY = b.getY() - a.getY();
double dist = APAUtils.getDistanceBetweenPoints(a, b);
double inc = 1.0 / dist;
CGPoint p = CGPoint.Zero();
for (double i = 0; i <= 1; i += inc) {
p.setX(a.getX() + i * deltaX);
p.setY(a.getY() + i * deltaY);
APADataMap point = queryLevelMap(p);
if (point.getWall() > 200) {
CGPoint wpos2 = convertLevelMapPointToWorldPoint(p);
return APAUtils.getDistanceBetweenPoints(pos0, wpos2);
}
}
return Float.MAX_VALUE;
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:24,代码来源:APAAdventureScene.java
示例18: canSee
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
@Override
public boolean canSee(CGPoint pos0, CGPoint pos1) {
CGPoint a = convertWorldPointToLevelMapPoint(pos0);
CGPoint b = convertWorldPointToLevelMapPoint(pos1);
double deltaX = b.getX() - a.getX();
double deltaY = b.getY() - a.getY();
double dist = APAUtils.getDistanceBetweenPoints(a, b);
double inc = 1.0 / dist;
CGPoint p = CGPoint.Zero();
for (double i = 0; i <= 1; i += inc) {
p.setX(a.getX() + i * deltaX);
p.setY(a.getY() + i * deltaY);
APADataMap point = queryLevelMap(p);
if (point.getWall() > 200) {
return false;
}
}
return true;
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:23,代码来源:APAAdventureScene.java
示例19: loadWorldTiles
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
private void loadWorldTiles() {
System.out.println("Loading world tiles");
NSDate startDate = new NSDate();
SKTextureAtlas tileAtlas = new SKTextureAtlas("Tiles");
sharedBackgroundTiles = new NSMutableArray<>(1024);
System.out.println("A");
for (int y = 0; y < WORLD_TILE_DIVISOR; y++) {
for (int x = 0; x < WORLD_TILE_DIVISOR; x++) {
int tileNumber = (y * WORLD_TILE_DIVISOR) + x;
SKSpriteNode tileNode = new SKSpriteNode(tileAtlas.getTexture(String
.format("tile%d.png", tileNumber)));
CGPoint position = new CGPoint((x * WORLD_TILE_SIZE) - WORLD_CENTER,
(WORLD_SIZE - (y * WORLD_TILE_SIZE))
- WORLD_CENTER);
tileNode.setPosition(position);
tileNode.setZPosition(-1.0);
tileNode.setBlendMode(SKBlendMode.Replace);
sharedBackgroundTiles.add(tileNode);
}
}
System.out.println(String.format("Loaded all world tiles in %f seconds",
new NSDate().getTimeIntervalSince(startDate)));
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:26,代码来源:APAAdventureScene.java
示例20: touchesBegan
import org.robovm.apple.coregraphics.CGPoint; //导入依赖的package包/类
@Override
public void touchesBegan(NSSet<UITouch> touches, UIEvent event) {
// We only support single touches, so any retrieves just that touch from
// touches.
UITouch touch = touches.any();
// Only move the placard view if the touch was in the placard view.
if (touch.getView() != placardView) {
// In case of a double tap outside the placard view, update the
// placard's display string.
if (touch.getTapCount() == 2) {
setupNextDisplayString();
}
return;
}
// Animate the first touch.
CGPoint touchPoint = touch.getLocationInView(this);
animateFirstTouch(touchPoint);
}
开发者ID:robovm,项目名称:robovm-samples,代码行数:21,代码来源:APLMoveMeView.java
注:本文中的org.robovm.apple.coregraphics.CGPoint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论