I believe you should be more specific and show more of your code so forum members could help you. What you are trying to achieve doesn't sounds complex and should work with a quick fixes.
@Tom2012. You can't do it the way you suggest in Lua. You can't pass objects by pointer or by reference (as far as I know). However, what you can do is pass in a table which you can alter the contents of. And, indeed, that table could be the scene containing the score.
CaveScene=Core.class()function CaveScene:init()
self.score=0end
...
function Caveman:bumpScore(scene)
scene.score=scene.score+1
....
end
I noticed in another discussion (I think it was you) that you said "it's amazing how a few words can make an application work" (you mistook stage for self or the other way around). What you are trying to do can be solved but I think you should study more about the value of "self" (like, what is "self" at self.scoreText:setText(tostring(score))) and solve it yourself, so you will be able to solve the same kind of scope issues that you'll have to face in the future.
Comments
What you are trying to achieve doesn't sounds complex and should work with a quick fixes.
Is that what you are trying to achieve?
I have a class that spawns characters on screen. Here's some of it...
Thanks for the example but I need to update the scene from the spawn class, not the other way around - if that makes sense.
Thanks Mells
Likes: Tom2012
What you are trying to do can be solved but I think you should study more about the value of "self" (like, what is "self" at self.scoreText:setText(tostring(score))) and solve it yourself, so you will be able to solve the same kind of scope issues that you'll have to face in the future.
Thank you. That's exactly what I was looking for.
Can't believe it was so simple. :0)