Skip to content

Admob integration #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GUI/bg_music1.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

stream = ExtResource( 1 )
volume_db = -15.0
pitch_scale = 1.0
autoplay = true
mix_target = 0
bus = "Master"
Expand Down
11 changes: 4 additions & 7 deletions GUI/player_controls.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[ext_resource path="res://Sprites/Gui/Buttons/normal/pause_normal.png" type="Texture" id=8]
[ext_resource path="res://Sprites/Gui/Buttons/pressed/pause_pressed.png" type="Texture" id=9]

[node name="player_controls" type="CanvasLayer"]
[node name="player_controls" type="CanvasLayer" index="0"]

layer = 1
offset = Vector2( 0, 0 )
Expand All @@ -21,8 +21,7 @@ script = ExtResource( 1 )

[node name="left" type="TouchScreenButton" parent="." index="0"]

position = Vector2( 40.538, 290.31 )
scale = Vector2( 1.3, 1.3 )
position = Vector2( 40.538, 265.31 )
normal = ExtResource( 2 )
pressed = ExtResource( 3 )
bitmask = null
Expand All @@ -36,8 +35,7 @@ _sections_unfolded = [ "Transform" ]

[node name="right" type="TouchScreenButton" parent="." index="1"]

position = Vector2( 129.992, 288.694 )
scale = Vector2( 1.3, 1.3 )
position = Vector2( 129.992, 263.694 )
normal = ExtResource( 4 )
pressed = ExtResource( 5 )
bitmask = null
Expand All @@ -51,8 +49,7 @@ _sections_unfolded = [ "Transform" ]

[node name="up" type="TouchScreenButton" parent="." index="2"]

position = Vector2( 549.629, 288.694 )
scale = Vector2( 1.3, 1.3 )
position = Vector2( 549.629, 263.694 )
normal = ExtResource( 6 )
pressed = ExtResource( 7 )
bitmask = null
Expand Down
72 changes: 69 additions & 3 deletions GUI/start_Gui.gd
Original file line number Diff line number Diff line change
@@ -1,15 +1,54 @@
extends Node
#Ads variables
var admob = null
var isReal = true
var isTop = false
var adBannerId = "ca-app-pub-3940256099942544/6300978111" # [Replace with your Ad Unit ID and delete this message.]
var adInterstitialId = "ca-app-pub-3940256099942544/1033173712" # [Replace with your Ad Unit ID and delete this message.]
var adRewardedId = "ca-app-pub-3940256099942544/5224354917" # [There is no testing option for rewarded videos, so you can use this id for testing]


func _ready():
$buttons/play_btn.connect("released",self,"on_play_btn_released")

#var deviceSize = OS.get_screen_size()
#print(deviceSize)
#var appSize = Vector2(deviceSize.x , deviceSize.y)
#OS.window_size.x = deviceSize.x
#OS.window_size.y = deviceSize.y
print(OS.get_screen_size())
#OS.window_size = OS.get_screen_size()

#OS.screen_orientation = 0

#Ads
if(Engine.has_singleton("AdMob")):
admob = Engine.get_singleton("AdMob")
admob.init(isReal, get_instance_id())
loadBanner()
loadInterstitial()
loadRewardedVideo()
get_tree().connect("screen_resized", self, "onResize")
#Ads

#$buttons/play_btn.connect("released",self,"on_play_btn_released")
$buttons/s_btn/sound_btn.connect("released",self,"on_sound_btn_released")
$buttons/m_btn/music_btn.connect("released",self,"on_music_btn_released")
pass

func loadBanner():
if admob != null:
admob.loadBanner(adBannerId, isTop)

pass

func on_play_btn_released():

func _on_play_btn_released():
get_tree().change_scene("Levels/World1.tscn")
pass
pass # replace with function body

#func on_play_btn_released():

# pass

func on_sound_btn_released():
if global.sound:
Expand All @@ -28,3 +67,30 @@ func on_music_btn_released():
global.music = true
$buttons/m_btn.set_texture(load("res://Sprites/Gui/Buttons/normal/music_normal.png"))
pass


#Admob functions
func _on_admob_network_error():
print("Network Error")


func _on_admob_ad_loaded():
print("Ad loaded success")


func _on_settings_btn_pressed():
if admob != null:
admob.showBanner()
pass # replace with function body

func onResize():
if admob != null:
admob.resize()

#func _on_settings_btn_released():
# if admob != null:
# admob.hideBanner()
# pass # replace with function body



40 changes: 23 additions & 17 deletions GUI/start_Gui.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
[ext_resource path="res://Sprites/Backgrounds/world1_bg.png" type="Texture" id=2]
[ext_resource path="res://Tiles/TailesWithGras.tres" type="TileSet" id=3]
[ext_resource path="res://Sprites/Player/Idle0.png" type="Texture" id=4]
[ext_resource path="res://Sprites/Player/Jump3.png" type="Texture" id=5]
[ext_resource path="res://Sprites/Player/Jump4.png" type="Texture" id=6]
[ext_resource path="res://Sprites/Player/Jump0.png" type="Texture" id=5]
[ext_resource path="res://Sprites/Player/Jump1.png" type="Texture" id=6]
[ext_resource path="res://Sprites/Player/Run0.png" type="Texture" id=7]
[ext_resource path="res://Sprites/Player/Run1.png" type="Texture" id=8]
[ext_resource path="res://Sprites/Player/Run2.png" type="Texture" id=9]
[ext_resource path="res://Sprites/Player/Run3.png" type="Texture" id=10]
[ext_resource path="res://Sprites/Player/Run4.png" type="Texture" id=11]
[ext_resource path="res://Sprites/Player/Run7.png" type="Texture" id=12]
[ext_resource path="res://Sprites/Player/Jump0.png" type="Texture" id=13]
[ext_resource path="res://Sprites/Player/Jump1.png" type="Texture" id=14]
[ext_resource path="res://Sprites/Player/Jump3.png" type="Texture" id=13]
[ext_resource path="res://Sprites/Player/Jump4.png" type="Texture" id=14]
[ext_resource path="res://Sounds/Player sounds/jump.wav" type="AudioStream" id=15]
[ext_resource path="res://Scenes/coin.tscn" type="PackedScene" id=16]
[ext_resource path="res://Scenes/Chest.tscn" type="PackedScene" id=17]
Expand All @@ -39,23 +39,23 @@ animations = [ {
}, {
"frames": [ ExtResource( 5 ), ExtResource( 6 ) ],
"loop": true,
"name": "fall",
"speed": 5.0
"name": "jump",
"speed": 2.0
}, {
"frames": [ ExtResource( 7 ), ExtResource( 8 ), ExtResource( 9 ), ExtResource( 10 ), ExtResource( 11 ), ExtResource( 12 ) ],
"loop": true,
"name": "run",
"speed": 10.0
}, {
"frames": [ ExtResource( 13 ), ExtResource( 14 ) ],
"loop": true,
"name": "fall",
"speed": 5.0
}, {
"frames": [ ExtResource( 10 ), ExtResource( 11 ) ],
"loop": false,
"name": "fire",
"speed": 1.0
}, {
"frames": [ ExtResource( 13 ), ExtResource( 14 ) ],
"loop": true,
"name": "jump",
"speed": 2.0
} ]

[sub_resource type="CapsuleShape2D" id=2]
Expand Down Expand Up @@ -237,8 +237,8 @@ _sections_unfolded = [ "Transform" ]

[node name="level_btn" type="TouchScreenButton" parent="buttons" index="1"]

position = Vector2( 278.226, 288.815 )
scale = Vector2( 0.9, 0.9 )
position = Vector2( 290.226, 262.815 )
scale = Vector2( 0.6, 0.6 )
normal = ExtResource( 21 )
pressed = ExtResource( 22 )
bitmask = null
Expand All @@ -252,8 +252,8 @@ _sections_unfolded = [ "Transform" ]

[node name="achievement_btn" type="TouchScreenButton" parent="buttons" index="2"]

position = Vector2( 160, 288 )
scale = Vector2( 0.9, 0.9 )
position = Vector2( 172, 262 )
scale = Vector2( 0.6, 0.6 )
normal = ExtResource( 23 )
pressed = ExtResource( 24 )
bitmask = null
Expand All @@ -267,8 +267,8 @@ _sections_unfolded = [ "Transform" ]

[node name="settings_btn" type="TouchScreenButton" parent="buttons" index="3"]

position = Vector2( 392.96, 288 )
scale = Vector2( 0.9, 0.9 )
position = Vector2( 404.96, 262 )
scale = Vector2( 0.6, 0.6 )
normal = ExtResource( 25 )
pressed = ExtResource( 26 )
bitmask = null
Expand Down Expand Up @@ -324,4 +324,10 @@ action = ""
visibility_mode = 0
_sections_unfolded = [ "Transform" ]

[connection signal="released" from="buttons/play_btn" to="." method="_on_play_btn_released"]

[connection signal="pressed" from="buttons/settings_btn" to="." method="_on_settings_btn_pressed"]

[connection signal="released" from="buttons/settings_btn" to="." method="_on_settings_btn_released"]


6 changes: 5 additions & 1 deletion Levels/World1.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[ext_resource path="res://Scenes/Chest.tscn" type="PackedScene" id=15]
[ext_resource path="res://GUI/bg_music1.tscn" type="PackedScene" id=16]

[node name="World" type="Node" index="0"]
[node name="World" type="Node"]

_sections_unfolded = [ "Pause" ]

Expand All @@ -37,6 +37,8 @@ position = Vector2( 132.355, 147.259 )

[node name="Tiles" type="Node" parent="." index="2"]

editor/display_folded = true

[node name="TileMap" type="TileMap" parent="Tiles" index="0"]

position = Vector2( 0, -264 )
Expand Down Expand Up @@ -215,4 +217,6 @@ position = Vector2( 4019.88, 328.59 )

[node name="bg_music1" parent="." index="9" instance=ExtResource( 16 )]

pitch_scale = 1.0


10 changes: 5 additions & 5 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ patch_list=PoolStringArray( )

graphics/32_bits_framebuffer=true
one_click_deploy/clear_previous_install=true
custom_package/debug=""
custom_package/release=""
custom_package/debug="C:/Users/B4DNetwork/GodotProjects/Export templates/debug_release export template/android_debug.apk"
custom_package/release="C:/Users/B4DNetwork/GodotProjects/Export templates/debug_release export template/android_release.apk"
command_line/extra_args=""
version/code=1
version/name="1.0"
package/unique_name="com.MrWho.$genname"
package/unique_name="com.godotth.$genname"
package/name=""
package/signed=true
screen/immersive_mode=true
Expand Down Expand Up @@ -47,7 +47,7 @@ permissions/access_coarse_location=false
permissions/access_fine_location=false
permissions/access_location_extra_commands=false
permissions/access_mock_location=false
permissions/access_network_state=false
permissions/access_network_state=true
permissions/access_surface_flinger=false
permissions/access_wifi_state=false
permissions/account_manager=false
Expand Down Expand Up @@ -108,7 +108,7 @@ permissions/install_location_provider=false
permissions/install_packages=false
permissions/install_shortcut=false
permissions/internal_system_window=false
permissions/internet=false
permissions/internet=true
permissions/kill_background_processes=false
permissions/location_hardware=false
permissions/manage_accounts=false
Expand Down
8 changes: 7 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

config_version=3

[android]

modules="org/godotengine/godot/GodotAdMob"

[application]

config/name="GoPe"
Expand All @@ -22,9 +26,11 @@ global="*res://global_variables.gd"

window/size/width=640
window/size/height=380
window/size/borderless=true
window/size/fullscreen=true
window/size/test_width=1280
window/size/test_height=720
window/handheld/orientation="sensor_landscape"
window/handheld/orientation="sensor"
window/handheld/emulate_touchscreen=true
window/stretch/mode="2d"

Expand Down