global var scope?

Discuss the ZGameEditor Visualizer plugin for FL-Studio.

Moderator: Moderators

Posts: 47
Joined: Mon May 30, 2011 8:10 pm

global var scope?

Postby Mic » Sun Jul 10, 2011 7:47 pm

This has to be me :-)

In the Ballz example where iX and iY are declared as vars owned by the model, I have created 2 global vars, mX and mY, and everywhere in the xml where iX, iY are touched, I do the same thing with mX and mY.

And it does not work - only getting 1 model instance where there should be 30. Am checking values with RenderText and mX and mY are behaving.

It is behaving as though

CurrentModel.Position.X += 2*App.DeltaTime * (ballsPosition[mX, mY, X_COORD] - CurrentModel.Position.X); //Model.OnUpdate

the model cannot use global vars to set its position, but this does not compute ... global = global, right?

Not sure whether there is enough info here but thoughts appreciated,



User avatar
Posts: 1648
Joined: Sat Feb 23, 2008 11:15 pm

Postby Kjell » Sun Jul 10, 2011 7:56 pm


Why would you want to use global variables for the instance index to begin with? Doesn't make a whole lot of sense to me ..

Sounds like you currently do have 30 instances, but they all grab the same position data from the Array ( which makes sense if you're not manipulating the global variables from the instances themselves ), so it appears like there is just one. Check the log for the number of spawned Models in your scene.


Posts: 47
Joined: Mon May 30, 2011 8:10 pm

ah with you ...

Postby Mic » Sun Jul 10, 2011 8:23 pm

reason I added the global var was that I could swap models in and out using the same update code - instead of adding iX1, iX2, iX3 for each model. But I think you might be right - I do have 30 but they are superimposed - thanks for the tip. Guess I should find another way of easily substituting models!

Return to “ZGameEditor Visualizer”

Who is online

Users browsing this forum: No registered users and 1 guest