• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Achievements类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.android.gms.games.achievement.Achievements的典型用法代码示例。如果您正苦于以下问题:Java Achievements类的具体用法?Java Achievements怎么用?Java Achievements使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Achievements类属于com.google.android.gms.games.achievement包,在下文中一共展示了Achievements类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: achievement_unlock_immediate

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
/**
 * Unlock an achievement with a given id immediately
 * with a callback result
 *
 * @param achievement_id achievement id obtained from your Developer Console
 *
 * Usage:
 *      const ST_OK = "STATUS_OK"
 *      var achievement_toasty = "achievemnt123ID"
 *
 *      ...
 *
 *      gpgs.achievement_unlock_immediate(achievement_toasty)
 *
 *
 *      ...
 *
 *      func _on_achievement_unlocked(id, status):
 *          if status == ST_OK:
 *              //succeeded action
 *          else:
 *              //failed action
 */
public void achievement_unlock_immediate(final String achievement_id) {
    logMethod();

    if(!isConnectedLogged()) return;

    achievements.unlockImmediate(
            achievement_id,
            new ResultCallback<Achievements.UpdateAchievementResult>() {
                @Override
                public void onResult(@NonNull Achievements.UpdateAchievementResult updateAchievementResult) {
                    String status = extractStatusNameFromStatus(
                            updateAchievementResult.getStatus().toString());

                    Log.d(TAG, MODULE
                            + ": > tried to unlock achievement " + achievement_id
                            + " with " + status);

                           GodotLib.calldeferred(
                                   instance_id, "_on_achievement_unlocked",
                                   new Object[] { achievement_id, status });

                }
            });
}
 
开发者ID:drtwisted,项目名称:godot-google-play-game-services,代码行数:48,代码来源:GodotPlayGameServices.java


示例2: achievement_reveal_immediate

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
/**
 * Reveal a hidden achievement with a given id immediately
 * with a callback result
 *
 * @param achievement_id achievement id obtained from your Developer Console
 *
 * Usage:
 *      const ST_OK = "STATUS_OK"
 *      var achievement_toasty = "achievemnt123ID"
 *
 *      ...
 *
 *      gpgs.achievement_reveal_immediate(achievement_toasty)
 *
 *      ....
 *
 *      func _on_achievement_revealed(id, status):
 *          if status == ST_OK:
 *              //succeeded action
 *          else:
 *              //failed action
 */
public void achievement_reveal_immediate(final String achievement_id) {
    logMethod();

    if (!isConnectedLogged()) return;

    achievements.revealImmediate(
            achievement_id,
            new ResultCallback<Achievements.UpdateAchievementResult>() {
                @Override
                public void onResult(@NonNull Achievements.UpdateAchievementResult updateAchievementResult) {
                    String status = extractStatusNameFromStatus(
                            updateAchievementResult.getStatus().toString());

                    Log.d(TAG, MODULE
                            + ": > tried to reveal achievement " + achievement_id
                            + " with " + status);

                           GodotLib.calldeferred(
                                   instance_id, "_on_achievement_revealed",
                                   new Object[] { achievement_id, status });
                }
            });
}
 
开发者ID:drtwisted,项目名称:godot-google-play-game-services,代码行数:46,代码来源:GodotPlayGameServices.java


示例3: achievement_increment_immediate

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
/**
 * Increment an achievement with a given id by a given amount of points immediately
 * with a callback result
 *
 * @param achievement_id achievement id obtained from your Developer Console
 * @param increment_amount ammount of points to increment the achievement by
 *
 * Usage:
 *      const ST_OK = "STATUS_OK"
 *      var achievement_toasty = "achievemnt123ID"
 *
 *      ...
 *
 *      gpgs.achievement_reveal_immediate(achievement_toasty)
 *
 *      ....
 *
 *      func _on_achievement_revealed(id, increment_amount, status):
 *          if status == ST_OK:
 *              //succeeded action
 *          else:
 *              //failed action
 */
public void achievement_increment_immediate(final String achievement_id, final int increment_amount) {
    logMethod();

    if(!isConnectedLogged()) return;

    achievements.incrementImmediate(
            achievement_id, increment_amount,
            new ResultCallback<Achievements.UpdateAchievementResult>() {
                @Override
                public void onResult(@NonNull Achievements.UpdateAchievementResult updateAchievementResult) {
                    String status = extractStatusNameFromStatus(
                            updateAchievementResult.getStatus().toString());

                    Log.d(TAG, MODULE
                            + ": > tried to increment achievement " + achievement_id
                            +" by " + String.valueOf(increment_amount)
                            + " with " + status);

                           GodotLib.calldeferred(
                                   instance_id, "_on_achievement_incremented",
                                   new Object[] { achievement_id, increment_amount, status });

                }
            });
}
 
开发者ID:drtwisted,项目名称:godot-google-play-game-services,代码行数:49,代码来源:GodotPlayGameServices.java


示例4: call

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public FREObject call( FREContext context, FREObject[] args ) {
	super.call( context, args );

	AIR.log( "GameServices::unlockAchievement" );
	String achievementId = FREObjectUtils.getString( args[0] );
	boolean immediate = FREObjectUtils.getBoolean( args[1] );

	GameServicesHelper helper = GameServicesHelper.getInstance();
	if( helper.isAuthenticated() ) {
		if( immediate ) {
			PendingResult<Achievements.UpdateAchievementResult> result = Games.Achievements.unlockImmediate( helper.getClient(), achievementId );
			result.setResultCallback( this, 10, TimeUnit.SECONDS );
			return null;
		}

		Games.Achievements.unlock( helper.getClient(), achievementId );
		AIR.log( "Successfully unlocked achievement: " + achievementId );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_UPDATE_SUCCESS );
	} else {
		helper.dispatchAchievementUpdateError();
	}

	return null;
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:26,代码来源:UnlockAchievementFunction.java


示例5: call

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public FREObject call( FREContext context, FREObject[] args ) {
	super.call( context, args );

	AIR.log( "GameServices::loadAchievements" );

	if( GameServicesHelper.getInstance().isAuthenticated() ) {
		PendingResult<Achievements.LoadAchievementsResult> result = Games.Achievements.load( GameServicesHelper.getInstance().getClient(), false );
		result.setResultCallback( this, 10, TimeUnit.SECONDS );
	} else {
		AIR.log( "User is not signed in." );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_LOAD_ERROR, "User is not signed in." );
	}

	return null;
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:17,代码来源:LoadAchievementsFunction.java


示例6: onResult

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public void onResult( @NonNull Achievements.LoadAchievementsResult result ) {
	com.google.android.gms.common.api.Status status = result.getStatus();

	if( !status.isSuccess() ) {
		result.release();
		AIR.log( "Failed to load achievements: " + status.getStatusMessage() );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_LOAD_ERROR, status.getStatusMessage() );
		return;
	}

	JSONArray achievementsArray = GSAchievementUtils.toJSONArray( result.getAchievements() );
	result.release();
	JSONObject response = new JSONObject();
	try {
		response.put( "achievements", achievementsArray );
		AIR.log( "Successfully loaded achievements" );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_LOAD_SUCCESS, response.toString() );
	} catch( JSONException e ) {
		e.printStackTrace();
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_LOAD_ERROR, e.getMessage() );
	}
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:24,代码来源:LoadAchievementsFunction.java


示例7: call

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public FREObject call( FREContext context, FREObject[] args ) {
	super.call( context, args );

	AIR.log( "GameServices::revealAchievement" );
	String achievementId = FREObjectUtils.getString( args[0] );
	boolean immediate = FREObjectUtils.getBoolean( args[1] );

	GameServicesHelper helper = GameServicesHelper.getInstance();
	if( helper.isAuthenticated() ) {
		if( immediate ) {
			PendingResult<Achievements.UpdateAchievementResult> result = Games.Achievements.revealImmediate( helper.getClient(), achievementId );
			result.setResultCallback( this, 10, TimeUnit.SECONDS );
			return null;
		}

		Games.Achievements.reveal( helper.getClient(), achievementId );
		AIR.log( "Successfully revealed achievement: " + achievementId );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_UPDATE_SUCCESS );
	} else {
		helper.dispatchAchievementUpdateError();
	}

	return null;
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:26,代码来源:RevealAchievementFunction.java


示例8: call

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public FREObject call( FREContext context, FREObject[] args ) {
	super.call( context, args );

	AIR.log( "GameServices::setAchievementSteps" );
	String achievementId = FREObjectUtils.getString( args[0] );
	int numSteps = FREObjectUtils.getInt( args[1] );
	boolean immediate = FREObjectUtils.getBoolean( args[2] );

	GameServicesHelper helper = GameServicesHelper.getInstance();
	if( helper.isAuthenticated() ) {
		if( immediate ) {
			PendingResult<Achievements.UpdateAchievementResult> result = Games.Achievements.setStepsImmediate( helper.getClient(), achievementId, numSteps );
			result.setResultCallback( this, 10, TimeUnit.SECONDS );
			return null;
		}

		Games.Achievements.setSteps( helper.getClient(), achievementId, numSteps );
		AIR.log( "Successfully set steps for achievement: " + achievementId );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_UPDATE_SUCCESS );
	} else {
		helper.dispatchAchievementUpdateError();
	}

	return null;
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:27,代码来源:SetAchievementStepsFunction.java


示例9: call

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public FREObject call( FREContext context, FREObject[] args ) {
	super.call( context, args );

	AIR.log( "GameServices::incrementAchievement" );
	String achievementId = FREObjectUtils.getString( args[0] );
	int numSteps = FREObjectUtils.getInt( args[1] );
	boolean immediate = FREObjectUtils.getBoolean( args[2] );

	GameServicesHelper helper = GameServicesHelper.getInstance();
	if( helper.isAuthenticated() ) {
		if( immediate ) {
			PendingResult<Achievements.UpdateAchievementResult> result = Games.Achievements.incrementImmediate( helper.getClient(), achievementId, numSteps );
			result.setResultCallback( this, 10, TimeUnit.SECONDS );
			return null;
		}

		Games.Achievements.increment( helper.getClient(), achievementId, numSteps );
		AIR.log( "Successfully incremented steps for achievement: " + achievementId );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_UPDATE_SUCCESS );
	} else {
		helper.dispatchAchievementUpdateError();
	}

	return null;
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:27,代码来源:IncrementAchievementFunction.java


示例10: t

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
public Achievements.LoadAchievementsResult t(final Status paramStatus)
{
  return new Achievements.LoadAchievementsResult()
  {
    public AchievementBuffer getAchievements()
    {
      return new AchievementBuffer(DataHolder.empty(14));
    }

    public Status getStatus()
    {
      return paramStatus;
    }

    public void release()
    {
    }
  };
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:20,代码来源:fs.java


示例11: setIncrement

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
public void setIncrement(boolean callback, String incrementId, int numSteps) {
	if (!callback) {
		Games.Achievements.increment(mGoogleApiClient, incrementId,
				numSteps);
	} else {
		Games.Achievements.incrementImmediate(mGoogleApiClient,
				incrementId, numSteps).setResultCallback(
				new ResultCallback<Achievements.UpdateAchievementResult>() {
					@Override
					public void onResult(
							Achievements.UpdateAchievementResult updateAchievementResult) {
						if (mCallback != null) {
							mCallback.onActionResult(ActionType.INCREMENT,
									getStatusResult(updateAchievementResult
											.getStatus()));
						}
					}
				});
	}
}
 
开发者ID:sadisasha,项目名称:PlayGames,代码行数:21,代码来源:PlayGamesServices.java


示例12: setReveal

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
public void setReveal(boolean callback, String revealId) {
	if (!callback) {
		Games.Achievements.reveal(mGoogleApiClient, revealId);
	} else {
		Games.Achievements
				.revealImmediate(mGoogleApiClient, revealId)
				.setResultCallback(
						new ResultCallback<Achievements.UpdateAchievementResult>() {
							@Override
							public void onResult(
									Achievements.UpdateAchievementResult updateAchievementResult) {
								if (mCallback != null) {
									mCallback
											.onActionResult(
													ActionType.REVEAL,
													getStatusResult(updateAchievementResult
															.getStatus()));
								}
							}
						});
	}
}
 
开发者ID:sadisasha,项目名称:PlayGames,代码行数:23,代码来源:PlayGamesServices.java


示例13: setSetSteps

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
public void setSetSteps(boolean callback, String stepsId, int numSteps) {
	if (!callback) {
		Games.Achievements.setSteps(mGoogleApiClient, stepsId, numSteps);
	} else {
		Games.Achievements.setStepsImmediate(mGoogleApiClient, stepsId,
				numSteps).setResultCallback(
				new ResultCallback<Achievements.UpdateAchievementResult>() {
					@Override
					public void onResult(
							Achievements.UpdateAchievementResult updateAchievementResult) {
						if (mCallback != null) {
							mCallback.onActionResult(ActionType.SET_STEPS,
									getStatusResult(updateAchievementResult
											.getStatus()));
						}
					}
				});
	}
}
 
开发者ID:sadisasha,项目名称:PlayGames,代码行数:20,代码来源:PlayGamesServices.java


示例14: setUnlockAchievement

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
public void setUnlockAchievement(boolean callback, String achievementId) {
	if (!callback) {
		Games.Achievements.unlock(mGoogleApiClient, achievementId);
	} else {
		Games.Achievements
				.unlockImmediate(mGoogleApiClient, achievementId)
				.setResultCallback(
						new ResultCallback<Achievements.UpdateAchievementResult>() {
							@Override
							public void onResult(
									Achievements.UpdateAchievementResult updateAchievementResult) {
								if (mCallback != null) {
									mCallback
											.onActionResult(
													ActionType.UNLOCK,
													getStatusResult(updateAchievementResult
															.getStatus()));
								}
							}
						});
	}
}
 
开发者ID:sadisasha,项目名称:PlayGames,代码行数:23,代码来源:PlayGamesServices.java


示例15: showAchievements

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public void showAchievements() throws GameServiceException {
    if (isSessionActive())
        myContext.startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient),
                RC_ACHIEVEMENTS);
    else
        throw new GameServiceException.NoSessionException();

}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:10,代码来源:GpgsClient.java


示例16: fetchAchievementsSync

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
public boolean fetchAchievementsSync(IFetchAchievementsResponseListener callback) {
    if (!isSessionActive())
        return false;

    Achievements.LoadAchievementsResult achievementsResult = Games.Achievements.load(
            mGoogleApiClient, forceRefresh).await();

    if (!achievementsResult.getStatus().isSuccess()) {
        Gdx.app.log(GAMESERVICE_ID, "Failed to fetch achievements:" +
                achievementsResult.getStatus().getStatusMessage());
        callback.onFetchAchievementsResponse(null);
        return false;
    }

    AchievementBuffer achievements = achievementsResult.getAchievements();

    Array<IAchievement> gpgsAchs = new Array<IAchievement>(achievements.getCount());

    for (Achievement ach : achievements) {
        GpgsAchievement gpgsAchievement = new GpgsAchievement();

        gpgsAchievement.achievementId = ach.getAchievementId();
        gpgsAchievement.achievementMapper = gpgsAchievementIdMapper;
        gpgsAchievement.description = ach.getDescription();
        gpgsAchievement.title = ach.getName();

        if (ach.getState() == Achievement.STATE_UNLOCKED)
            gpgsAchievement.percCompl = 1f;
        else if (ach.getType() == Achievement.TYPE_INCREMENTAL)
            gpgsAchievement.percCompl = (float) ach.getCurrentSteps() / ach.getTotalSteps();

        gpgsAchs.add(gpgsAchievement);
    }

    achievements.release();

    callback.onFetchAchievementsResponse(gpgsAchs);

    return true;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:41,代码来源:GpgsClient.java


示例17: unlockAchievement

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public boolean unlockAchievement(String achievementId) {
    if (gpgsAchievementIdMapper != null)
        achievementId = gpgsAchievementIdMapper.mapToGsId(achievementId);

    if (achievementId != null && isSessionActive()) {
        Games.Achievements.unlock(mGoogleApiClient, achievementId);
        return true;
    } else
        return false;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:12,代码来源:GpgsClient.java


示例18: incrementAchievement

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public boolean incrementAchievement(String achievementId, int incNum, float completionPercentage) {
    if (gpgsAchievementIdMapper != null)
        achievementId = gpgsAchievementIdMapper.mapToGsId(achievementId);

    if (achievementId != null && isSessionActive()) {
        // GPGS supports passing a value for incrementation, no need to use completionPercentage
        Games.Achievements.increment(mGoogleApiClient, achievementId, incNum);
        return true;
    } else
        return false;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:13,代码来源:GpgsClient.java


示例19: initClient

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
private void initClient() {
    if (client != null) return;
    
    client = new Client(this, activity, TAG, MODULE, debug);
    client.init();
    player = new PlayerInfo(client, activity, TAG, MODULE, debug);
    leaderboards = new org.godotengine.godot.gpgs.Leaderboards(
            client, activity, TAG, MODULE, debug);
    achievements = new org.godotengine.godot.gpgs.Achievements(
            client, activity, TAG, MODULE, debug);
}
 
开发者ID:drtwisted,项目名称:godot-google-play-game-services,代码行数:12,代码来源:GodotPlayGameServices.java


示例20: onResult

import com.google.android.gms.games.achievement.Achievements; //导入依赖的package包/类
@Override
public void onResult( @NonNull Achievements.UpdateAchievementResult result ) {
	com.google.android.gms.common.api.Status status = result.getStatus();

	if( !status.isSuccess() ) {
		AIR.log( "Failed to unlock achievement: " + status.getStatusMessage() );
		AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_UPDATE_ERROR, status.getStatusMessage() );
		return;
	}

	AIR.log( "Successfully unlocked achievement" );
	AIR.dispatchEvent( GameServicesEvent.ACHIEVEMENT_UPDATE_SUCCESS );
}
 
开发者ID:marpies,项目名称:game-services-ane,代码行数:14,代码来源:UnlockAchievementFunction.java



注:本文中的com.google.android.gms.games.achievement.Achievements类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IScatterDataSet类代码示例发布时间:2022-05-22
下一篇:
Java NodeStatusProtoOrBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap