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 = getnode("res://scenes/powerup.tscn")
func physicsprocess(delta):
motion.y += 10
if Input.isactionpressed("uiright"):
motion.x += speed
anim.play("right")
anim.fliph = false
elif Input.isactionpressed("uileft"):
motion.x -= speed
anim.play("left")
anim.fliph = 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):
jumpheight = 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):
gettree().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.