当前位置: 首页>>代码示例>>Java>>正文


Java CGPoint.Zero方法代码示例

本文整理汇总了Java中org.robovm.apple.coregraphics.CGPoint.Zero方法的典型用法代码示例。如果您正苦于以下问题:Java CGPoint.Zero方法的具体用法?Java CGPoint.Zero怎么用?Java CGPoint.Zero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.robovm.apple.coregraphics.CGPoint的用法示例。


在下文中一共展示了CGPoint.Zero方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: TilingView

import org.robovm.apple.coregraphics.CGPoint; //导入方法依赖的package包/类
public TilingView(String imageName, CGSize size) {
    super(new CGRect(CGPoint.Zero(), size));
    this.imageName = imageName;

    CATiledLayer tiledLayer = (CATiledLayer) getLayer();
    tiledLayer.setLevelsOfDetail(4);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:8,代码来源:TilingView.java

示例4: createGradientImage

import org.robovm.apple.coregraphics.CGPoint; //导入方法依赖的package包/类
public static CGImage createGradientImage(int pixelsWide, int pixelsHigh) {
    CGImage image = null;

    // Our gradient is always black-white and the mask
    // must be in the gray colorspace
    CGColorSpace colorSpace = CGColorSpace.createDeviceGray();

    // create the bitmap context
    CGBitmapContext gradientBitmapContext = CGBitmapContext.create(pixelsWide, pixelsHigh, 8, 0, colorSpace,
            new CGBitmapInfo(CGImageAlphaInfo.None.value()));
    if (gradientBitmapContext != null) {
        // define the start and end grayscale values (with the alpha, even
        // though
        // our bitmap context doesn't support alpha the gradient requires
        // it)
        CGColor[] colors = new CGColor[] { CGColor.create(colorSpace, new double[] { 0.0, 1.0 }),
            CGColor.create(colorSpace, new double[] { 1.0, 1.0 }) };
        // create the CGGradient
        CGGradient grayScaleGradient = CGGradient.create(colorSpace, colors, (double[]) null);
        // create the start and end points for the gradient vector (straight
        // down)
        CGPoint gradientStartPoint = CGPoint.Zero();
        CGPoint gradientEndPoint = new CGPoint(0, pixelsHigh);
        // draw the gradient into the gray bitmap context
        gradientBitmapContext.drawLinearGradient(grayScaleGradient, gradientStartPoint, gradientEndPoint,
                CGGradientDrawingOptions.AfterEndLocation);
        // convert the context into a CGImage
        image = gradientBitmapContext.toImage();
    }

    // return the image containing the gradient
    return image;
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:34,代码来源:AtomicElementView.java

示例5: update

import org.robovm.apple.coregraphics.CGPoint; //导入方法依赖的package包/类
@Override
public void update (double timeInterval) {
    APACave cave = (APACave)character;

    if (cave.health <= 0.0) {
        return;
    }

    APAMultiplayerLayeredCharacterScene scene = cave.getCharacterScene();

    double closestHeroDistance = MINIMUM_HERO_DISTANCE;
    CGPoint closestHeroPosition = CGPoint.Zero();

    CGPoint cavePosition = cave.getPosition();

    for (SKNode hero : scene.getHeroes()) {
        CGPoint heroPosition = hero.getPosition();
        double distance = APAUtils.getDistanceBetweenPoints(cavePosition, heroPosition);
        if (distance < closestHeroDistance) {
            closestHeroDistance = distance;
            closestHeroPosition = heroPosition;
        }
    }

    double distScale = closestHeroDistance / MINIMUM_HERO_DISTANCE;

    // Generate goblins more quickly if the closest hero is getting closer.
    cave.timeUntilNextGenerate -= timeInterval;

    // Either time to generate or the hero is so close we need to respond ASAP!
    int goblinCount = cave.activeGoblins.size();
    if (goblinCount < 1 || cave.timeUntilNextGenerate <= 0.0 || (distScale < 0.35 && cave.timeUntilNextGenerate > 5.0)) {
        if (goblinCount < 1
            || (goblinCount < 4 && closestHeroPosition.equalsTo(CGPoint.Zero()) && scene.canSee(closestHeroPosition,
                cave.getPosition()))) {
            cave.generate();
        }
        cave.timeUntilNextGenerate = 4.0 * distScale;
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:41,代码来源:APASpawnAI.java

示例6: configureController

import org.robovm.apple.coregraphics.CGPoint; //导入方法依赖的package包/类
private void configureController(GCController controller, final APAPlayer player) {
    int playerIndex = players.indexOf(player);
    System.out.println(String.format("Assigning %s to player %s [%d]", controller.getVendorName(), player,
            playerIndex));

    // Assign the controller to the player.
    player.controller = controller;

    VoidBlock3<GCControllerDirectionPad, Float, Float> dpadMoveHandler = new VoidBlock3<GCControllerDirectionPad, Float, Float>() {
        @Override
        public void invoke(GCControllerDirectionPad dpad, Float xValue, Float yValue) {
            double length = Math.hypot(xValue, yValue);
            if (length > 0) {
                double invLength = 1f / length;
                player.heroMoveDirection = new CGPoint(xValue * invLength, yValue * invLength);
            } else {
                player.heroMoveDirection = CGPoint.Zero();
            }
        }
    };

    // Use either the dpad or the left thumbstick to move the character.
    controller.getExtendedGamepad().getLeftThumbstick().setValueChangedHandler(dpadMoveHandler);
    controller.getGamepad().getDpad().setValueChangedHandler(dpadMoveHandler);

    VoidBlock3<GCControllerButtonInput, Float, Boolean> fireButtonHandler = new VoidBlock3<GCControllerButtonInput, Float, Boolean>() {
        @Override
        public void invoke(GCControllerButtonInput a, Float b, Boolean pressed) {
            player.fireAction = pressed;
        }
    };

    controller.getGamepad().getButtonA().setValueChangedHandler(fireButtonHandler);
    controller.getGamepad().getButtonB().setValueChangedHandler(fireButtonHandler);

    if (player != defaultPlayer && player.hero == null) {
        addHeroForPlayer(player);
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:40,代码来源:APAMultiplayerLayeredCharacterScene.java

示例7: getMinimumContentOffset

import org.robovm.apple.coregraphics.CGPoint; //导入方法依赖的package包/类
private CGPoint getMinimumContentOffset() {
    return CGPoint.Zero();
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:4,代码来源:ImageScrollView.java

示例8: didSimulatePhysics

import org.robovm.apple.coregraphics.CGPoint; //导入方法依赖的package包/类
@Override
    public void didSimulatePhysics() {
        super.didSimulatePhysics();

        // Get the position either of the default hero or the hero spawn point.
        APAHeroCharacter defaultHero = defaultPlayer.hero;
        CGPoint position = CGPoint.Zero();
        if (defaultHero != null && heroes.contains(defaultHero)) {
            position = defaultHero.getPosition();
        } else {
            position = defaultSpawnPoint;
        }

        // Update the alphas of any trees that are near the hero (center of the
        // camera) and therefore visible or soon to be
// visible.
        for (APATree tree : trees) {
            if (APAUtils.getDistanceBetweenPoints(tree.getPosition(), position) < 1024) {
                tree.updateAlpha(this);
            }
        }

        if (!worldMovedForUpdate) {
            return;
        }

        // Show any nearby hidden particle systems and hide those that are too
        // far away to be seen.
        for (SKEmitterNode particles : particleSystems) {
            boolean particlesAreVisible = APAUtils.getDistanceBetweenPoints(particles.getPosition(), position) < 1024;

            if (!particlesAreVisible && !particles.isPaused()) {
                particles.setPaused(true);
            } else if (particlesAreVisible && particles.isPaused()) {
                particles.setPaused(false);
            }
        }

        // Update nearby parallax sprites.
        for (APAParallaxSprite sprite : parallaxSprites) {
            if (APAUtils.getDistanceBetweenPoints(sprite.getPosition(), position) >= 1024) {
                continue;
            }

            sprite.updateOffset();
        }
    }
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:48,代码来源:APAAdventureScene.java


注:本文中的org.robovm.apple.coregraphics.CGPoint.Zero方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。