本文整理汇总了Java中org.robovm.apple.coregraphics.CGPoint.setX方法的典型用法代码示例。如果您正苦于以下问题:Java CGPoint.setX方法的具体用法?Java CGPoint.setX怎么用?Java CGPoint.setX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.robovm.apple.coregraphics.CGPoint
的用法示例。
在下文中一共展示了CGPoint.setX方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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));
}
}
}
示例3: 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;
}
示例4: 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;
}
示例5: recoverFromResizing
import org.robovm.apple.coregraphics.CGPoint; //导入方法依赖的package包/类
private void recoverFromResizing() {
setMaxMinZoomScalesForCurrentBounds();
// Step 1: restore zoom scale, first making sure it is within the
// allowable range.
double maxZoomScale = Math.max(getMinimumZoomScale(), scaleToRestoreAfterResize);
setZoomScale(Math.min(getMaximumZoomScale(), maxZoomScale));
// Step 2: restore center point, first making sure it is within the
// allowable range.
// 2a: convert our desired center point back to our own coordinate space
CGPoint boundsCenter = convertPointFromView(pointToCenterAfterResize, zoomView);
// 2b: calculate the content offset that would yield that center point
CGPoint offset = new CGPoint(boundsCenter.getX() - getBounds().getSize().getWidth() / 2.0, boundsCenter.getY()
- getBounds().getSize().getHeight() / 2.0);
// 2c: restore offset, adjusted to be within the allowable range
CGPoint maxOffset = getMaximumContentOffset();
CGPoint minOffset = getMinimumContentOffset();
double realMaxOffset = Math.min(maxOffset.getX(), offset.getX());
offset.setX(Math.max(minOffset.getX(), realMaxOffset));
realMaxOffset = Math.min(maxOffset.getY(), offset.getY());
offset.setY(Math.max(minOffset.getY(), realMaxOffset));
setContentOffset(offset);
}
示例6: startLevel
import org.robovm.apple.coregraphics.CGPoint; //导入方法依赖的package包/类
public void startLevel() {
APAHeroCharacter hero = addHeroForPlayer(defaultPlayer);
if (MOVE_NEAR_TO_BOSS) {
CGPoint bossPosition = levelBoss.getPosition(); // set earlier from
// buildWorld in
// addSpawnPoints
bossPosition.setX(bossPosition.getX() + 128);
bossPosition.setY(bossPosition.getY() + 512);
hero.setPosition(bossPosition);
}
centerWorldOnCharacter(hero);
}
示例7: convertLevelMapPointToWorldPoint
import org.robovm.apple.coregraphics.CGPoint; //导入方法依赖的package包/类
private CGPoint convertLevelMapPointToWorldPoint(CGPoint location) {
// Given a level map pixel point, convert up to a world point.
// This determines which "tile" the point falls in and centers within
// that tile.
int x = (int) ((location.getX() * LEVEL_MAP_DIVISOR) - (WORLD_CENTER * WORLD_TILE_SIZE / 2));
int y = (int) -((location.getY() * LEVEL_MAP_DIVISOR) - (WORLD_CENTER * WORLD_TILE_SIZE / 2));
location.setX(x);
location.setY(y);
return location;
}
示例8: convertWorldPointToLevelMapPoint
import org.robovm.apple.coregraphics.CGPoint; //导入方法依赖的package包/类
private CGPoint convertWorldPointToLevelMapPoint(CGPoint location) {
// Given a world based point, resolve to a pixel location in the level
// map.
int x = (int) ((location.getX() + WORLD_CENTER) / LEVEL_MAP_DIVISOR);
int y = (int) ((WORLD_SIZE - (location.getY() + WORLD_CENTER)) / LEVEL_MAP_DIVISOR);
location.setX(x);
location.setY(y);
return location;
}
示例9: didSimulatePhysics
import org.robovm.apple.coregraphics.CGPoint; //导入方法依赖的package包/类
@Override
public void didSimulatePhysics() {
APAHeroCharacter defaultHero = defaultPlayer.hero;
// Move the world relative to the default player position.
if (defaultHero != null) {
CGPoint heroPosition = defaultHero.getPosition();
CGPoint worldPos = world.getPosition();
double yCoordinate = worldPos.getY() + heroPosition.getY();
if (yCoordinate < MIN_HERO_TO_EDGE_DISTANCE) {
worldPos.setY(worldPos.getY() - yCoordinate + MIN_HERO_TO_EDGE_DISTANCE);
worldMovedForUpdate = true;
} else if (yCoordinate > (getFrame().getSize().getHeight() - MIN_HERO_TO_EDGE_DISTANCE)) {
worldPos.setY(worldPos.getY() + (getFrame().getSize().getHeight() - yCoordinate)
- MIN_HERO_TO_EDGE_DISTANCE);
worldMovedForUpdate = true;
}
double xCoordinate = worldPos.getX() + heroPosition.getX();
if (xCoordinate < MIN_HERO_TO_EDGE_DISTANCE) {
worldPos.setX(worldPos.getX() - xCoordinate + MIN_HERO_TO_EDGE_DISTANCE);
worldMovedForUpdate = true;
} else if (xCoordinate > (getFrame().getSize().getHeight() - MIN_HERO_TO_EDGE_DISTANCE)) {
worldPos.setX(worldPos.getX() + (getFrame().getSize().getWidth() - xCoordinate)
- MIN_HERO_TO_EDGE_DISTANCE);
worldMovedForUpdate = true;
}
world.setPosition(worldPos);
}
// Using performSelector:withObject:afterDelay: withg a delay of 0.0
// means that the selector call occurs after
// the current pass through the run loop.
// This means the property will be cleared after the subclass
// implementation of didSimulatePhysics completes.
performSelector(clearWorldMoved, null, 0.0);
}
示例10: inflate
import org.robovm.apple.coregraphics.CGPoint; //导入方法依赖的package包/类
@Override
public void inflate(Element element) throws ParseException {
RotateDrawableConstantState state = internalConstantState;
Map<String, String> attrs = DOMUtil.getAttributesFromElement(element);
CGPoint pivot = new CGPoint(0.5d, 0.5d);
boolean pivotXRelative = true;
boolean pivotYRelative = true;
if(ResourceAttributesUtil.isFractionValue(attrs, "pivotX")) {
pivot.setX(ResourceAttributesUtil.getFractionValue(attrs, "pivotX"));
} else if(attrs.containsKey("pivotX")) {
pivot.setX(ResourceAttributesUtil.getFractionValue(attrs, "pivotX", 0.5d));
pivotXRelative = false;
}
if(ResourceAttributesUtil.isFractionValue(attrs, "pivotY")) {
pivot.setY(ResourceAttributesUtil.getFractionValue(attrs, "pivotY"));
} else if(attrs.containsKey("pivotY")) {
pivot.setY(ResourceAttributesUtil.getFractionValue(attrs, "pivotY", 0.5d));
pivotYRelative = false;
}
state.setPivot(pivot);
state.setPivotXRelative(pivotXRelative);
state.setPivotYRelative(pivotYRelative);
double fromDegrees = ResourceAttributesUtil.getDimensionValue(attrs, "fromDegrees", 0.d);
double toDegrees = ResourceAttributesUtil.getDimensionValue(attrs, "toDegrees", 360.d);
toDegrees = Math.max(fromDegrees, toDegrees);
state.setCurrentDegrees(fromDegrees);
state.setFromDegrees(state.getCurrentDegrees());
state.setToDegrees(toDegrees);
String drawableResId = attrs.get("drawables");
Drawable drawable = null;
Element firstElementChild = DOMUtil.getFirstElementChild(element);
if(drawableResId != null) {
ResourceManager.getCurrent().getDrawable(drawableResId);
} else if(firstElementChild != null) {
drawable = Drawable.create(firstElementChild);
} else {
throw new ParseException("<item> tag requires a 'drawable' attribute or child tag defining a drawable", 0);
}
if(drawable != null) {
drawable.setDelegate(this);
drawable.setState(this.getState());
state.setDrawable(drawable);
}
}