Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | jebenipapa |
I have a backend setup which sends the user a random reward upon finishing the game.
Currently everything is working well however I don’t know how to read the result and display an image and label depending on what reward the user gets.
Any suggestions?
What I have currenly is:
func _on_Barrel01Area_input_event(viewport, event, shape_idx):
if (event is InputEventMouseButton && event.pressed):
get_tree().get_root().set_disable_input(true)
$SmasherSprite/SmasherAttack.play("smash")
yield(get_tree().create_timer(1.1), "timeout")
$Barrel01.play("idle")
yield(get_tree().create_timer(1.1), "timeout")
#random.randomize()
var x =1
if x == 1:
var reward = "Lawnmower"
$Barrel01.hide()
$Barrel02.hide()
$Barrel03.hide()
$SmasherSprite.hide()
$SelectedRewards.show_Lawnmower()
get_tree().get_root().set_disable_input(false)
var url = "http://localhost:8080/endGame"
var body = {"score": globals.score,"time": globals.time}
var token = JavaScript.eval("localStorage.getItem('TOKEN')")
var jsonBody = JSON.print(body)
$HTTPRequest.request(url, ["Authorization: %s" % token, "Content-length: %d" % jsonBody.length(), "Content-type: application/json"], false, HTTPClient.METHOD_POST, jsonBody)
#$HTTPRequest.request(url, [], true, HTTPClient.METHOD_POST)
And