org.robovm.apple.foundation.NSArray Java Examples

The following examples show how to use org.robovm.apple.foundation.NSArray. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GameCenterClient.java    From gdx-gamesvcs with Apache License 2.0 6 votes vote down vote up
@Override
public boolean incrementAchievement(String achievementId, int incNum, float completionPercentage) {
	if (isSessionActive() && achievementId != null) {
		GKAchievement achievement = new GKAchievement(achievementId);
		achievement.setPercentComplete(completionPercentage * 100);
		achievement.setShowsCompletionBanner(true);
		// Create an array with the achievement
		NSArray<GKAchievement> achievements = new NSArray<>(achievement);
		GKAchievement.reportAchievements(achievements, new VoidBlock1<NSError>() {
			@Override
			public void invoke (NSError error) {
				// do nothing
			}
		});

		return true;
	}

	return false;
}
 
Example #2
Source File: APACharacter.java    From robovm-samples with Apache License 2.0 6 votes vote down vote up
private void fireAnimation (final APAAnimationState animationState, NSArray<SKTexture> frames, String key) {
    SKAction animAction = getAction(key);
    if (animAction != null | frames.size() < 1) {
        return;// we already have a running animation or there aren't any frames to animate
    }

    activeAnimationKey = key;

    runAction(SKAction.sequence(new NSArray<SKAction>(SKAction.animateFrames(frames, animationSpeed, true, false), SKAction
        .run(new Runnable() {
            @Override
            public void run () {
                animationHasCompleted(animationState);
            }
        }))), key);
}
 
Example #3
Source File: APACave.java    From robovm-samples with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: AAPLAssetViewController.java    From robovm-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void viewWillAppear(boolean animated) {
    super.viewWillAppear(animated);

    if (asset.getMediaType() == PHAssetMediaType.Video) {
        setToolbarItems(new NSArray<UIBarButtonItem>(playButton, space, trashButton));
    } else {
        setToolbarItems(new NSArray<UIBarButtonItem>(space, trashButton));
    }

    boolean isEditable = asset.canPerformEditOperation(PHAssetEditOperation.Properties)
            || asset.canPerformEditOperation(PHAssetEditOperation.Content);
    editButton.setEnabled(isEditable);

    boolean isTrashable = false;
    if (assetCollection != null) {
        isTrashable = assetCollection.canPerformEditOperation(PHCollectionEditOperation.RemoveContent);
    } else {
        isTrashable = asset.canPerformEditOperation(PHAssetEditOperation.Delete);
    }
    trashButton.setEnabled(isTrashable);

    getView().layoutIfNeeded();
    updateImage();
}
 
Example #5
Source File: PhotosViewController.java    From robovm-samples with Apache License 2.0 6 votes vote down vote up
@Override
public UIPageViewControllerSpineLocation getSpineLocation(UIPageViewController pageViewController,
        UIInterfaceOrientation orientation) {
    // Set the spine position to "min" and the page view controller's view
    // controllers array to contain just one view
    // controller. Setting the spine position to
    // 'UIPageViewControllerSpineLocationMid' in landscape orientation sets
    // the doubleSided property to YES, so set it to NO here.
    UIViewController currentViewController = pageViewController.getViewControllers().get(0);

    NSArray<UIViewController> viewControllers = new NSArray<>(currentViewController);

    pageViewController.setViewControllers(viewControllers, UIPageViewControllerNavigationDirection.Forward, true,
            null);

    pageViewController.setDoubleSided(false);
    return UIPageViewControllerSpineLocation.Min;
}
 
Example #6
Source File: APAMultiplayerLayeredCharacterScene.java    From robovm-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void touchesBegan(NSSet<UITouch> touches, UIEvent event) {
    if (heroes.size() < 1) {
        return;
    }
    UITouch touch = touches.any();

    if (defaultPlayer.movementTouch != null) {
        return;
    }

    defaultPlayer.targetLocation = touch.getLocationInNode(defaultPlayer.hero.getParent());

    boolean wantsAttack = false;
    NSArray<SKNode> nodes = getNodesAtPoint(touch.getLocationInNode(this));
    for (SKNode node : nodes) {
        if (((node.getPhysicsBody().getCategoryBitMask() & APAColliderType.Cave) == APAColliderType.Cave)
                || ((node.getPhysicsBody().getCategoryBitMask() & APAColliderType.GoblinOrBoss) == APAColliderType.GoblinOrBoss)) {
            wantsAttack = true;
        }
    }

    defaultPlayer.fireAction = wantsAttack;
    defaultPlayer.moveRequested = !wantsAttack;
    defaultPlayer.movementTouch = touch;
}
 
Example #7
Source File: PAPUtility.java    From robovm-samples with Apache License 2.0 6 votes vote down vote up
public static void unfollowUsersEventually(List<PAPUser> users) {
    PFQuery<PAPActivity> query = PFQuery.getQuery(PAPActivity.class);
    query.whereEqualTo(PAPActivity.FROM_USER_KEY, PAPUser.getCurrentUser());
    query.whereContainedIn(PAPActivity.TO_USER_KEY, new NSArray<PAPUser>(users));
    query.whereEqualTo(PAPActivity.TYPE_KEY, PAPActivityType.FOLLOW.getKey());
    query.findInBackground(new PFFindCallback<PAPActivity>() {
        @Override
        public void done(NSArray<PAPActivity> activities, NSError error) {
            for (PAPActivity activity : activities) {
                activity.deleteEventually();
            }
        }
    });
    for (PAPUser user : users) {
        PAPCache.getSharedCache().setUserFollowStatus(user, false);
    }
}
 
Example #8
Source File: APAGoblin.java    From robovm-samples with Apache License 2.0 6 votes vote down vote up
public static void loadSharedAssets() {
    // Load only once
    if (sharedDamageEmitter == null) {
        SKTextureAtlas atlas = new SKTextureAtlas("Environment");

        sharedIdleAnimationFrames = APAUtils
                .loadFramesFromAtlas("Goblin/Goblin_Idle", "goblin_idle_", DEFAULT_NUMBER_OF_IDLE_FRAMES);
        sharedWalkAnimationFrames = APAUtils
                .loadFramesFromAtlas("Goblin/Goblin_Walk", "goblin_walk_", DEFAULT_NUMBER_OF_WALK_FRAMES);
        sharedAttackAnimationFrames = APAUtils.loadFramesFromAtlas("Goblin/Goblin_Attack", "goblin_attack_",
                ATTACK_FRAMES);
        sharedGetHitAnimationFrames = APAUtils.loadFramesFromAtlas("Goblin/Goblin_GetHit", "goblin_getHit_",
                GET_HIT_FRAMES);
        sharedDeathAnimationFrames = APAUtils.loadFramesFromAtlas("Goblin/Goblin_Death", "goblin_death_",
                DEATH_FRAMES);
        sharedDamageEmitter = APAUtils.getEmitterNodeByName("Damage");
        sharedDeathSplort = new SKSpriteNode(atlas.getTexture("minionSplort.png"));
        sharedDamageAction = SKAction.sequence(new NSArray<SKAction>(SKAction.colorize(UIColor.white(), 1.0, 0.0),
                SKAction
                        .wait(0.75), SKAction.colorize(0.0, 0.1)));

    }
}
 
Example #9
Source File: APABoss.java    From robovm-samples with Apache License 2.0 6 votes vote down vote up
public static void loadSharedAssets() {
    // Load only once.
    if (sharedDamageEmitter == null) {
        sharedIdleAnimationFrames = APAUtils.loadFramesFromAtlas("Boss/Boss_Idle", "boss_idle_", IDLE_FRAMES);
        sharedWalkAnimationFrames = APAUtils.loadFramesFromAtlas("Boss/Boss_Walk", "boss_walk_", WALK_FRAMES);
        sharedAttackAnimationFrames = APAUtils.loadFramesFromAtlas("Boss/Boss_Attack", "boss_attack_",
                ATTACK_FRAMES);
        sharedGetHitAnimationFrames = APAUtils.loadFramesFromAtlas("Boss/Boss_GetHit", "boss_getHit_",
                GET_HIT_FRAMES);
        sharedDeathAnimationFrames = APAUtils.loadFramesFromAtlas("Boss/Boss_Death", "boss_death_", DEATH_FRAMES);

        sharedDamageEmitter = APAUtils.getEmitterNodeByName("BossDamage");
        sharedDamageAction = SKAction.sequence(new NSArray<SKAction>(SKAction.colorize(UIColor.white(), 1.0, 0.0),
                SKAction
                        .wait(0.5), SKAction.colorize(0.0, 0.1)));
    }
}
 
Example #10
Source File: PAPPhotoDetailsViewController.java    From robovm-samples with Apache License 2.0 6 votes vote down vote up
@Override
public double getHeightForRow(UITableView tableView, NSIndexPath indexPath) {
    NSArray<PAPActivity> objects = getObjects();
    if (indexPath.getRow() < objects.size()) { // A comment row
        PAPActivity object = objects.get(indexPath.getRow());

        if (object != null) {
            String commentString = object.getContent();

            PAPUser commentAuthor = object.getFromUser();

            String nameString = "";
            if (commentAuthor != null) {
                nameString = commentAuthor.getDisplayName();
            }

            return PAPActivityCell.getHeightForCell(nameString, commentString, CELL_INSET_WIDTH);
        }
    }

    // The pagination row
    return 44;
}
 
Example #11
Source File: GameCenterClient.java    From gdx-gamesvcs with Apache License 2.0 6 votes vote down vote up
@Override
public boolean submitToLeaderboard(String leaderboardId, long score, String tag) {
	if (isSessionActive() && leaderboardId != null) {
		GKScore scoreReporter = new GKScore();
		scoreReporter.setValue(score);
		scoreReporter.setLeaderboardIdentifier(leaderboardId);
		NSArray<GKScore> scores = new NSArray<>(scoreReporter);
		GKScore.reportScores(scores, new VoidBlock1<NSError>() {
			@Override
			public void invoke (NSError error) {
				// ignore errors
			}
		});
		return true;
	}

	return false;
}
 
Example #12
Source File: GameCenterClient.java    From gdx-gamesvcs with Apache License 2.0 6 votes vote down vote up
@Override
public boolean fetchGameStates(final IFetchGameStatesListResponseListener callback) {
    if (!isSessionActive())
        return false;

    GKLocalPlayer.getLocalPlayer().fetchSavedGames(new VoidBlock2<NSArray<GKSavedGame>, NSError>() {
        @Override
        public void invoke(NSArray<GKSavedGame> savedGames, NSError error) {
            if (error == null && savedGames != null) {
                Array<String> gameStates = new Array<String>(savedGames.size());

                for (GKSavedGame snapshot : savedGames) {
                    gameStates.add(snapshot.getName());
                }

                callback.onFetchGameStatesListResponse(gameStates);
            } else {
                callback.onFetchGameStatesListResponse(null);
            }
        }
    });
    return true;
}
 
Example #13
Source File: PAPFindFriendsViewController.java    From robovm-samples with Apache License 2.0 6 votes vote down vote up
@Override
public PFQuery<PAPUser> getQuery() {
    // Use cached facebook friend ids
    List<String> facebookFriends = PAPCache.getSharedCache().getFacebookFriends();

    // Query for all friends you have on facebook and who are using the app
    PFQuery<PAPUser> friendsQuery = PFQuery.getQuery(PAPUser.class);
    friendsQuery.whereContainedIn(PAPUser.FACEBOOK_ID_KEY, facebookFriends);

    // Query for all Parse employees
    List<String> parseEmployees = new ArrayList<>(PARSE_EMPLOYEE_ACCOUNTS);
    parseEmployees.remove(PAPUser.getCurrentUser().getFacebookId());
    PFQuery<PAPUser> parseEmployeeQuery = PFQuery.getQuery(PAPUser.class);
    parseEmployeeQuery.whereContainedIn(PAPUser.FACEBOOK_ID_KEY, parseEmployees);

    PFQuery<PAPUser> query = PFQuery.or(new NSArray<PFQuery<?>>(friendsQuery, parseEmployeeQuery));
    query.setCachePolicy(PFCachePolicy.NetworkOnly);

    if (getObjects().size() == 0) {
        query.setCachePolicy(PFCachePolicy.CacheThenNetwork);
    }

    query.orderByAscending(PAPUser.DISPLAY_NAME_KEY);

    return query;
}
 
Example #14
Source File: FriendsViewController.java    From robovm-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void viewWillAppear(boolean animated) {
    super.viewWillAppear(animated);

    FacebookHandler.getInstance().requestFriends(new FacebookHandler.RequestListener() {
        @SuppressWarnings("unchecked")
        @Override
        public void onSuccess(NSObject result) {
            FacebookHandler.log("Friends result: %s", result);

            NSDictionary<NSString, ?> root = (NSDictionary<NSString, ?>) result;
            friends = (NSArray<NSDictionary<NSString, ?>>) root
                    .get(new NSString("data"));
            getTableView().reloadData();
        }

        @Override
        public void onError(String message) {
            FacebookHandler.getInstance().alertError("Error while getting a list of your friends!", message);
        }

        @Override
        public void onCancel() {}
    });
}
 
Example #15
Source File: APACave.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void performDeath () {
    super.performDeath();

    SKNode splort = (SKNode)sharedDeathSplort.copy();
    splort.setZPosition(-1.0);
    splort.setZPosition(-1.0);
    splort.setZRotation(virtualZRotation);
    splort.setPosition(getPosition());
    splort.setAlpha(0.1);
    splort.runAction(SKAction.fadeAlphaTo(1.0, 0.5));

    APAMultiplayerLayeredCharacterScene scene = getCharacterScene();

    scene.addNode(splort, APAWorldLayer.BelowCharacter);

    runAction(SKAction.sequence(new NSArray<SKAction>(SKAction.fadeAlphaTo(0.0, 0.5), SKAction.removeFromParent())));

    smokeEmitter.runAction(SKAction.sequence(new NSArray<SKAction>(SKAction.wait(2.0), SKAction.run(new Runnable() {
        @Override
        public void run () {
            smokeEmitter.setParticleBirthRate(2.0);
        }
    }), SKAction.wait(2.0), SKAction.run(new Runnable() {
        @Override
        public void run () {
            smokeEmitter.setParticleBirthRate(0.0);
        }
    }), SKAction.wait(10.0), SKAction.fadeAlphaTo(0.0, 0.5), SKAction.removeFromParent())));
    inactiveGoblins.clear();
}
 
Example #16
Source File: PAPFindFriendsViewController.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
@Override
        public void onClick(UIBarButtonItem barButtonItem) {
//    [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES]; TODO
            configureFollowAllButton();

            DispatchQueue.getMainQueue().after(10, TimeUnit.MILLISECONDS, new Runnable() {
                @Override
                public void run() {
                    getNavigationItem()
                            .setRightBarButtonItem(
                                    new UIBarButtonItem("Follow All", UIBarButtonItemStyle.Plain,
                                            followAllFriendsButtonAction));

                    NSArray<NSIndexPath> indexPaths = new NSMutableArray<>();
                    NSArray<PAPUser> objects = getObjects();
                    UITableView tableView = getTableView();
                    for (int i = 0, n = objects.size(); i < n; i++) {
                        PAPUser user = objects.get(i);
                        NSIndexPath indexPath = NSIndexPath.row(i, 0);
                        PAPFindFriendsCell cell = (PAPFindFriendsCell) getCellForRow(tableView, indexPath, user);
                        cell.getFollowButton().setSelected(false);
                        indexPaths.add(indexPath);
                    }

                    tableView.reloadRows(indexPaths, UITableViewRowAnimation.None);
//        [MBProgressHUD hideAllHUDsForView:[UIApplication sharedApplication].keyWindow animated:YES]; TODO
                    PAPUtility.unfollowUsersEventually(objects);

                    PAPNotificationManager.postNotification(PAPNotification.USER_FOLLOWING_CHANGED);
                }
            });
        }
 
Example #17
Source File: APAUtils.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
public static NSArray<SKTexture> loadFramesFromAtlas (String atlasName, String baseFileName, int numberOfFrames) {
    NSArray<SKTexture> frames = new NSMutableArray<>(numberOfFrames);

    SKTextureAtlas atlas = new SKTextureAtlas(atlasName);
    for (int i = 1; i <= numberOfFrames; i++) {
        String fileName = String.format("%s%04d.png", baseFileName, i);
        SKTexture texture = atlas.getTexture(fileName);
        frames.add(texture);
    }

    return frames;
}
 
Example #18
Source File: AAPLAssetGridViewController.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
private NSArray<NSIndexPath> getIndexPathsForElementsInRect(CGRect rect) {
    NSArray<UICollectionViewLayoutAttributes> allLayoutAttributes = getCollectionViewLayout()
            .getLayoutAttributesForElements(
                    rect);
    if (allLayoutAttributes.size() == 0)
        return null;
    NSArray<NSIndexPath> indexPaths = new NSMutableArray<>(allLayoutAttributes.size());
    for (UICollectionViewLayoutAttributes layoutAttributes : allLayoutAttributes) {
        NSIndexPath indexPath = layoutAttributes.getIndexPath();
        indexPaths.add(indexPath);
    }
    return indexPaths;
}
 
Example #19
Source File: APACharacter.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
private void resolveRequestedAnimation () {
    // Determine the animation we want to play.
    String animationKey = null;
    NSArray<SKTexture> animationFrames = null;
    APAAnimationState animationState = requestedAnimation;

    switch (animationState) {
    default:
    case Idle:
        animationKey = "anim_idle";
        animationFrames = getIdleAnimationFrames();
        break;
    case Walk:
        animationKey = "anim_walk";
        animationFrames = getWalkAnimationFrames();
        break;
    case Attack:
        animationKey = "anim_attack";
        animationFrames = getAttackAnimationFrames();
        break;
    case GetHit:
        animationKey = "anim_gethit";
        animationFrames = getHitAnimationFrames();
        break;
    case Death:
        animationKey = "anim_death";
        animationFrames = getDeathAnimationFrames();
        break;
    }

    if (animationKey != null) {
        fireAnimation(animationState, animationFrames, animationKey);
    }

    requestedAnimation = dying ? APAAnimationState.Death : APAAnimationState.Idle;
}
 
Example #20
Source File: QuickContactsViewController.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
/**
 * This method is called when the user has granted access to their address
 * book data.
 */
private void accessGrantedForAddressBook() {
    // Load data from the plist file
    String plistPath = NSBundle.getMainBundle().findResourcePath("Menu", "plist");
    menuArray = (NSArray<NSDictionary<NSString, NSString>>) NSArray.read(new File(plistPath));
    getTableView().reloadData();
}
 
Example #21
Source File: PhotosViewController.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void didFinishAnimating(UIPageViewController pageViewController, boolean finished,
        NSArray<UIViewController> previousViewControllers, boolean completed) {

    // update the nav bar title showing which index we are displaying
    updateNavBarTitle();

    pageAnimationFinished = true;
}
 
Example #22
Source File: APAAdventureScene.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
@Override
void loadSceneAssets() {
    SKTextureAtlas atlas = new SKTextureAtlas("Environment");

    // Load archived emitters and create copyable sprites.
    sharedProjectileSparkEmitter = APAUtils.getEmitterNodeByName("ProjectileSplat");
    sharedSpawnEmitter = APAUtils.getEmitterNodeByName("Spawn");

    sharedSmallTree = new APATree(new NSArray<SKSpriteNode>(new SKSpriteNode(atlas
            .getTexture("small_tree_base.png")),
            new SKSpriteNode(atlas.getTexture("small_tree_middle.png")), new SKSpriteNode(atlas
                    .getTexture("small_tree_top.png"))), 25.0);
    sharedBigTree = new APATree(new NSArray<SKSpriteNode>(
            new SKSpriteNode(atlas.getTexture("big_tree_base.png")),
            new SKSpriteNode(atlas.getTexture("big_tree_middle.png")), new SKSpriteNode(atlas
                    .getTexture("big_tree_top.png"))), 150.0);
    sharedBigTree.setFadesAlpha(true);
    sharedLeafEmitterA = APAUtils.getEmitterNodeByName("Leaves_01");
    sharedLeafEmitterB = APAUtils.getEmitterNodeByName("Leaves_02");

    // Load the tiles that make up the ground layer.
    loadWorldTiles();

    // Load assets for all the sprites within this scene.
    APAArcher.loadSharedAssets();
    APABoss.loadSharedAssets();
    APACave.loadSharedAssets();
    APAGoblin.loadSharedAssets();
    APAHeroCharacter.loadSharedAssets();
    APAWarrior.loadSharedAssets();
}
 
Example #23
Source File: ShortcutsTableViewController.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
public ShortcutsTableViewController(NSCoder coder) {
    super(coder);
    NSDictionary<NSString, ?> info = NSBundle.getMainBundle().getInfoDictionary(); // TODO
                                                                                   // we
                                                                                   // could
                                                                                   // wrap
                                                                                   // it
    // Obtain the UIApplicationShortcutItems array from the Info.plist. If
    // unavailable, there are no static shortcuts.
    @SuppressWarnings("unchecked") NSArray<NSDictionary<NSString, ?>> shortcuts = (NSArray<NSDictionary<NSString, ?>>) info
            .get("UIApplicationShortcutItems");
    if (shortcuts == null) {
        staticShortcuts = new NSArray<>();
    } else {
        staticShortcuts = new NSMutableArray<>();
        for (NSDictionary<NSString, ?> shortcut : shortcuts) {
            String shortcutType = shortcut.getString("UIApplicationShortcutItemType");
            String shortcutTitle = shortcut.getString("UIApplicationShortcutItemTitle");

            String localizedTitle = NSBundle.getMainBundle().getLocalizedInfoDictionary()
                    .getString(shortcutTitle, null);
            if (localizedTitle != null) {
                shortcutTitle = localizedTitle;
            }

            String shortcutSubtitle = shortcut.getString("UIApplicationShortcutItemSubtitle", null);
            if (shortcutSubtitle != null) {
                shortcutSubtitle = NSBundle.getMainBundle().getLocalizedInfoDictionary()
                        .getString(shortcutSubtitle, null);
            }

            staticShortcuts.add(new UIApplicationShortcutItem(shortcutType, shortcutTitle, shortcutSubtitle, null,
                    null));
        }
    }
}
 
Example #24
Source File: APAWarrior.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
public static void loadSharedAssets() {
    // Load only once
    if (sharedProjectile == null) {
        SKTextureAtlas atlas = new SKTextureAtlas("Environment");

        sharedProjectile = new SKSpriteNode(atlas.getTexture("warrior_throw_hammer.png"));
        sharedProjectile.setPhysicsBody(SKPhysicsBody.createCircle(PROJECTILE_COLLISION_RADIUS));
        sharedProjectile.setName("Projectile");
        sharedProjectile.getPhysicsBody().setCategoryBitMask(APAColliderType.Projectile);
        sharedProjectile.getPhysicsBody().setCollisionBitMask(APAColliderType.Wall);
        sharedProjectile.getPhysicsBody().setContactTestBitMask(
                sharedProjectile.getPhysicsBody().getCollisionBitMask());

        sharedProjectileEmitter = APAUtils.getEmitterNodeByName("WarriorProjectile");
        sharedIdleAnimationFrames = APAUtils.loadFramesFromAtlas("Warrior/Warrior_Idle", "warrior_idle_",
                IDLE_FRAMES);
        sharedWalkAnimationFrames = APAUtils.loadFramesFromAtlas("Warrior/Warrior_Walk", "warrior_walk_",
                DEFAULT_NUMBER_OF_WALK_FRAMES);
        sharedAttackAnimationFrames = APAUtils.loadFramesFromAtlas("Warrior/Warrior_Attack", "warrior_attack_",
                THROW_FRAMES);
        sharedGetHitAnimationFrames = APAUtils.loadFramesFromAtlas("Warrior/Warrior_GetHit", "warrior_getHit_",
                GET_HIT_FRAMES);
        sharedDeathAnimationFrames = APAUtils.loadFramesFromAtlas("Warrior/Warrior_Death", "warrior_death_",
                DEATH_FRAMES);

        sharedDamageAction = SKAction.sequence(new NSArray<SKAction>(SKAction.colorize(UIColor.red(), 10, 0),
                SKAction
                        .wait(0.5), SKAction.colorize(0.0, 0.25)));
    }
}
 
Example #25
Source File: APAMultiplayerLayeredCharacterScene.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
private void updateHUDAfterHeroDeath(APAPlayer player) {
    int playerIndex = players.indexOf(player);

    // Fade out the relevant heart - one-based livesLeft has already been
    // decremented.
    int heartNumber = player.livesLeft;

    NSArray<SKSpriteNode> heartArray = hudLifeHeartArrays.get(playerIndex);
    SKSpriteNode heart = heartArray.get(heartNumber);
    heart.runAction(SKAction.fadeAlphaTo(0.0, 3.0));
}
 
Example #26
Source File: MyTableViewController.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Reveals the date picker inline for the given indexPath, called by
 * "didSelectRowAtIndexPath".
 * 
 * @param indexPath The indexPath to reveal the UIDatePicker.
 */
private void displayInlineDatePickerForRow(NSIndexPath indexPath) {
    // display the date picker inline with the table content
    getTableView().beginUpdates();

    boolean before = false; // indicates if the date picker is below
                            // "indexPath", help us determine which row to
                            // reveal
    if (hasInlineDatePicker()) {
        before = datePickerIndexPath.getRow() < indexPath.getRow();
    }

    boolean sameCellClicked = datePickerIndexPath != null && datePickerIndexPath.getRow() - 1 == indexPath.getRow();

    // remove any date picker cell if it exists
    if (hasInlineDatePicker()) {
        getTableView().deleteRows(
                new NSArray<NSIndexPath>(NSIndexPath.row(datePickerIndexPath.getRow(), 0)),
                UITableViewRowAnimation.Fade);
        datePickerIndexPath = null;
    }

    if (!sameCellClicked) {
        // hide the old date picker and display the new one
        long rowToReveal = before ? indexPath.getRow() - 1 : indexPath.getRow();
        NSIndexPath indexPathToReveal = NSIndexPath.row(rowToReveal, 0);

        toggleDatePicker(indexPathToReveal);
        datePickerIndexPath = NSIndexPath.row(indexPathToReveal.getRow() + 1, 0);
    }

    // always deselect the row containing the start or end date
    getTableView().deselectRow(indexPath, true);

    getTableView().endUpdates();

    // inform our date picker of the current date to match the current cell
    updateDatePicker();
}
 
Example #27
Source File: StoreObserver.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Logs all transactions that have been removed from the payment queue
 * 
 * @param queue
 * @param transactions
 */
@Override
public void removedTransactions(SKPaymentQueue queue, NSArray<SKPaymentTransaction> transactions) {
    for (SKPaymentTransaction transaction : transactions) {
        System.out
                .println(transaction.getPayment().getProductIdentifier() + " was removed from the payment queue.");
    }
}
 
Example #28
Source File: ApplicationShortcuts.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
@Override
public boolean didFinishLaunching(UIApplication application, UIApplicationLaunchOptions launchOptions) {
    // Override point for customization after application launch.
    boolean shouldPerformAdditionalDelegateHandling = true;

    // If a shortcut was launched, display its information and take the
    // appropriate action
    if (launchOptions != null) {
        launchedShortcutItem = launchOptions.getShortcutItem();
    }

    // This will block "performActionForShortcutItem:completionHandler" from
    // being called.
    shouldPerformAdditionalDelegateHandling = false;

    // Install initial versions of our two extra dynamic shortcuts.
    NSArray<UIApplicationShortcutItem> shortcutItems = application.getShortcutItems();
    if (shortcutItems == null || shortcutItems.isEmpty()) {
        // Construct the items.
        UIApplicationShortcutItem shortcut3 = new UIMutableApplicationShortcutItem(SHORTCUT_THIRD, "Play");
        shortcut3.setLocalizedSubtitle("Will Play an item");
        shortcut3.setIcon(new UIApplicationShortcutIcon(UIApplicationShortcutIconType.Play));
        NSDictionary<NSString, ?> info3 = new NSMutableDictionary<>();
        info3.put(APPLICATION_SHORTCUT_USER_INFO_ICON_KEY, UIApplicationShortcutIconType.Play.ordinal());
        shortcut3.setUserInfo(info3);

        UIApplicationShortcutItem shortcut4 = new UIMutableApplicationShortcutItem(SHORTCUT_FOURTH, "Pause");
        shortcut4.setLocalizedSubtitle("Will Pause an item");
        shortcut4.setIcon(new UIApplicationShortcutIcon(UIApplicationShortcutIconType.Pause));
        NSDictionary<NSString, ?> info4 = new NSMutableDictionary<>();
        info4.put(APPLICATION_SHORTCUT_USER_INFO_ICON_KEY, UIApplicationShortcutIconType.Pause.ordinal());
        shortcut4.setUserInfo(info4);

        // Update the application providing the initial 'dynamic' shortcut
        // items.
        application.setShortcutItems(new NSArray<>(shortcut3, shortcut4));
    }

    return shouldPerformAdditionalDelegateHandling;
}
 
Example #29
Source File: MyViewController.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
@IBAction
private void decreaseRating() {
    if (--this.rating < 0) {
        this.rating = 0;
        return;
    }

    NSArray<UIView> icons = this.ratingsStack.getArrangedSubviews();
    UIView lastIcon = icons.get(icons.size() - 1);
    this.ratingsStack.removeArrangedSubview(lastIcon);
    lastIcon.removeFromSuperview();

    UIView.animate(0.5, () -> this.ratingsStack.layoutIfNeeded());
}
 
Example #30
Source File: AMAnswerMeSDKImpl.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Converts a {@link List} of Java {@link Topic} objects to an
 * {@link NSArray} of {@link AMTopicImpl} objects.
 */
private NSArray<AMTopicImpl> toAMTopics(List<Topic> topics) {
    NSMutableArray<AMTopicImpl> result = new NSMutableArray<>(topics.size());
    for (Topic topic : topics) {
        result.add(new AMTopicImpl(topic));
    }
    return result;
}