在我的统一应用程序中,我集成了 Admob。这是我的“广告”类中的代码:
public static InterstitialAd interstitial;
private void Start()
{
RequestInterstitial();
}
public void StartAds()
{
RequestInterstitial();
if (interstitial.IsLoaded())
{
interstitial.Show();
}
else
{
Debug.Log("Interstitial wasn't loaded yet");
}
interstitial.Show();
}
public static void onAdLeftApplication()
{
ChangeCoinValue.actualCoinValue += 33;
PlayerPrefs.SetInt("TotalCoinValue", ChangeCoinValue.actualCoinValue);
}
private void RequestInterstitial()
{
// Initialize an InterstitialAd.
interstitial = new InterstitialAd(adUnitId);
// Create an empty ad request.
AdRequest request = new AdRequest.Builder().Build();
// Load the interstitial with the request.
interstitial.LoadAd(request);
}
Run Code Online (Sandbox Code Playgroud)
当我在另一个班级并打电话时,广告确实显示得很完美(例如,单击按钮:)
Ads.Interstitial.Show();
Run Code Online (Sandbox Code Playgroud)
我是这样做的,因为在单声道开发中你不能使用对象,所以它需要是静态的。但尽管如此:
因此,我认为每次用户点击广告并因此离开应用程序时,我的广告类“OnAdLeftApplication()”中的函数都会触发。如果他或她这样做,我会奖励这个人33个硬币!
但它不起作用。也许不是因为我只是从我的插页式广告中调用“show()”函数,但我不知道。
你能向我解释一下,当用户点击其中一个广告时,我如何用硬币奖励用户? …
所以我有这个小程序,我的播放器来回反弹.他向左移动的样子如下:
if ((runright == false) && (birdyDead == false))
{
float currentposition = 0;
currentposition = transform.position.x;
Vector3 position = this.transform.position;
position.x = currentposition - movespeed;
this.transform.position = position;
lookleft = true;
}
Run Code Online (Sandbox Code Playgroud)
然而,我注意到,根据我正在调试游戏的手机,玩家以不同的速度移动.在某些极端情况下,他只是太快了.喜欢无法控制的快速...我读到也许我需要以某种方式将某些值与time.deltatime相乘,这对帧速率有所作为,这样无论我使用什么手机我的播放器总是以相同的速度.我猜我也需要对我的跳跃功能这样做,对吧?:
if (((Input.GetMouseButtonDown(0)) && (didjump == false) && (birdyDead == false)))
{
GetComponent<Rigidbody2D>().AddForce(new Vector2(0, jumpPower), ForceMode2D.Impulse);
didjump = true;
anim.SetBool("Jump", true);
}
Run Code Online (Sandbox Code Playgroud)
你能帮助我并告诉我怎么做才能让我的玩家仍然按照我想要的速度移动,但是增量时间也在游戏中吗?谢谢 :)