Topic: Speedometer on another scene

Hi,
I haven't worked on the car game in a while so I thought I would get back to it.
So I've been trying to add a speedometer to my GUI scene. I have got a speedometer in my game scene which works, but I would prefer if it was stuck to the camera on the GUI scene. So far for my GUI scene i've got:

CarGame = getScene("CarGame")
Text2 = getObject("Text2")
Text0 = getObject(CarGame, "Text0")
function onSceneUpdate()
speedometer = getText(CarGame, "Text0")
setText(Text0, speedometer)
end

And on my game scene i've got:

setText(Text0, string.format("%.1f", speed))

The speed variable is included in the physics test demo already.
I feel like i'm missing something obvious here, but could anyone please help?

Last edited by Almighty Laxz (2012-10-18 21:31:23)

Re: Speedometer on another scene

Hi,

Maratis can only run one script at a time, from the current scene, for you the "CarGame" scene I think.

Just access directly your gui text from the main scene :

GuiScene = getScene("GuiScene")
GuiText = getObject(GuiScene, "Text2")

and in the update :

setText(GuiText, string.format("%.1f", speed))

Re: Speedometer on another scene

Thanks smile