0 votes

im working on a game where you can change the speed and jump accelerations during game. i was working on a pause menu for the game, the pausing works but i cant resume back to the game for example the game pauses but when i press resume it wont unpause.
script:
extends KinematicBody2D

var motion = Vector2()
const UP = Vector2(0,-1)
var speed = 100
var jumpheight = 300
onready var anim = $Sprite
var paused = false
onready var powerup = get
node("res://scenes/powerup.tscn")

func physicsprocess(delta):
motion.y += 10
if Input.isactionpressed("uiright"):
motion.x += speed
anim.play("right")
anim.flip
h = false
elif Input.isactionpressed("uileft"):
motion.x -= speed
anim.play("left")
anim.flip
h = true
elif Input.isactionjustpressed("uiaccept") and isonfloor():
motion.y = -jump_height
else:
motion.x = 0
anim.play("idle")

if Input.is_action_pressed("e"):
    speed = 10
    $"text/speed changed(fast)".hide()
    $"text/speed changed(slow)".show()
elif Input.is_action_pressed("q"):
    speed = 100
    $"text/speed changed(slow)".hide()
    $"text/speed changed(fast)".show()

motion = move_and_slide(motion, UP)
pass

if Input.is_action_pressed("ui_escape"):
    get_tree().paused = true
    $"Control/skilltree".show()
    $"Control/resume game".show()
    paused = true

func ondetectionnodebodyentered(powerup):
jump
height = 1000
pass # Replace with function body.

func onskilltree_pressed():
$"Control/high jump".show()
$"Control/running powerup".show()
pass # Replace with function body.

func onCheckButton2buttondown():
speed = 10
pass # Replace with function body.

func onCheckButton2buttonup():
speed = 100
pass # Replace with function body.

func onCheckButtonbuttondown():
speed = 10
pass # Replace with function body.

func onCheckButtonbuttonup():
speed = 100
pass # Replace with function body.

func onresumegametoggled(buttonpressed):
get
tree().paused = false
paused = false
$"Control/skilltree".hide()
$"Control/high jump".hide()
$"Control/running powerup".hide()
$"Control/resume game".hide()
pass

func onresumegamepressed():
if onresumegamepressed():
get_tree().paused = false
paused = false
$"Control/skilltree".hide()
$"Control/high jump".hide()
$"Control/running powerup".hide()
$"Control/resume game".hide()
pass # Replace with function body.

in Engine by (20 points)

Have you made sure the pause_mode-property of the node this script is attached to is set to "Process"? Otherwise _on_resume_game_toggled and _on_resume_game_pressed won't be called - thus the game won't unpause.

thanks it worked

1 Answer

0 votes

Hi, the resume is not working because is paused. You can fix it changing the pause property (in the inspector of the your resume node) from Inherit to Process.

by (55 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.