Comments (1)
Hi, your code is not wrong, but you are noticing this because you are not waiting for the reward_ad
to be loaded to click on the button, I did some modifications for you:
extends Button
var rewarded_ad : RewardedAd
var rewarded_ad_load_callback := RewardedAdLoadCallback.new()
var on_user_earned_reward_listener := OnUserEarnedRewardListener.new()
var _full_screen_content_callback := FullScreenContentCallback.new()
@export var reward_type : String
@export_category("skin")
@export var skin_name : String
func _ready():
rewarded_ad_load_callback.on_ad_failed_to_load = on_rewarded_ad_failed_to_load
rewarded_ad_load_callback.on_ad_loaded = on_rewarded_ad_loaded
on_user_earned_reward_listener.on_user_earned_reward = on_user_earned_reward
_full_screen_content_callback.on_ad_dismissed_full_screen_content = func() -> void:
your_button.disabled = true
if _rewarded_ad:
_rewarded_ad.destroy()
_rewarded_ad = null
load_ad()
your_button.disabled = true
load_ad()
func load_ad() -> void:
var unit_id : String
if OS.get_name() == "Android":
unit_id = "ca-app-pub-3940256099942544/5224354917"
elif OS.get_name() == "iOS":
unit_id = "ca-app-pub-3940256099942544/1712485313"
RewardedAdLoader.new().load(unit_id, AdRequest.new(), rewarded_ad_load_callback)
func on_rewarded_ad_failed_to_load(adError : LoadAdError) -> void:
print(adError.message)
func on_rewarded_ad_loaded(rewarded_ad : RewardedAd) -> void:
print("rewarded ad loaded " + str(rewarded_ad._uid))
self.rewarded_ad = rewarded_ad
self.rewarded_ad.full_screen_content_callback = _full_screen_content_callback
your_button.disabled = false
func on_user_earned_reward(rewarded_item : RewardedItem): # not using rewarded_item
print("on_user_earned_reward, rewarded_item: rewarded", rewarded_item.amount, rewarded_item.type)
func _on_pressed():
if rewarded_ad:
rewarded_ad.show(on_user_earned_reward_listener)
please always check the documentation and the code in the sample:
https://poing-studios.github.io/godot-admob-plugin/ad_formats/rewarded/
https://github.com/poing-studios/godot-admob-plugin/blob/v3.1.0/addons/admob/sample/Rewarded.gd
from godot-admob-android.
Related Issues (20)
- 3.0.0 Plugin is failing HOT 6
- Native ads support HOT 1
- Application crashes after opening ads HOT 2
- Thanks HOT 1
- The device's advertising IDs are not transmitted or processed. HOT 5
- How to show consent form again? HOT 3
- An Error when i change the test App-ID in the manifest HOT 1
- Just question HOT 4
- Parse Error: Function "get_plugin_version()" not found in base self. HOT 2
- Update for godot 4.2.0 stable HOT 7
- Provide Custom Export Template HOT 2
- v2.1.6 crashing without error HOT 3
- impression level ad revenue HOT 2
- Ad compatibility problem with devices HOT 7
- Admob android plugin shows black screen when enabled on Android API level 30
- Families Policy Requirements HOT 2
- Admob android plugin shows black screen when enabled on Android API level 30 HOT 2
- [FEATURE] Verify a new release version every day to release a new build
- TOP Banner Ad position is leaving a wide gap HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godot-admob-android.