如何验证谷歌在libgdx游戏应用程序内购买? [英] How to verify Google In app purchase in libgdx game?

查看:189
本文介绍了如何验证谷歌在libgdx游戏应用程序内购买?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照谷歌的开发人员指导实施在我Libgdx游戏应用内购买。
(我已经实现了谷歌玩游戏服务,所以我有一个想法如何睿code和Android特定code在LIBGdx游戏同步。)

I have Followed Google developers guide to implement In app purchases in my Libgdx game. (I have already implemented Google play game services so I do have an idea how Core code and Android specific code in LIBGdx game sync. )

不过,我很困惑,一旦我通过点击一个按钮,买了一个项目,我怎么能更新游戏状态。例如,如果我购买额外的生活在游戏中,我怎么可以更新主要code,它

But I am confused that once I bought an item by clicking on a button, how can I update the game state. For example if I buy extra life in game, how can I update In main code that

if (gdx.geType == ApplicationType.Android ) {
  // successfully bought a life 
  // add +1 life in my whole game model.
}

我从来没有合作过在应用内购买。
如果有人能指导我。我已经检查计算器关于在应用程序内购买其他线程,但我依然在它没有在那里。

I have never worked with In App purchases before. If somebody can guide me. I have checked stackoverflow other threads regarding In app purchases but I am still no where in it.

推荐答案

您需要为了你的核心项目(libgdx)和Android之间的项目谈创建一个接口。

You need to create an interface in order to talk between your core project (libgdx) and android project.


  1. 创建于核心项目的接口,并命名为任何你想要的。

  2. 然后创建一个类的内部Android项目可以说AndroidInterfaceImplementation它实现了你的核心工程中创建的界面。

  3. 在Android的MainActivity这是在Android项目在onCreate方法初始化Libgdx项目之前,Android的实例InterfaceImplementation。

  4. 过关游戏类中的接口

  5. 然后在核项目中的游戏类,你将有机会获得的接口。通过添加方法的界面,您可以两个项目之间的访问。

类似的事情在这个线程讨论:

Something similar was discussed in this thread:

libGDX警告对话框

检查最后的答案

这篇关于如何验证谷歌在libgdx游戏应用程序内购买?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆