How? 12/07/09

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

How? 12/07/09

Post by y offs et »

So I'm happy because I've solved the tricky internal coding of my project. Now to make it user friendly.

I would like to make the Timer"pause"/Interval user adjustable.

Any ideas?
Attachments
pauseTimer.jpg
pauseTimer.jpg (20.52 KiB) Viewed 12746 times
User avatar
Kjell
Posts: 1929
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hmm,

There are a couple of factors you didn't describe that are of influence on such a decision.

Do you want to set the timer for each clone individually or globally from some sort of options screen. When globally, should you be able to change the value while clones are in play, and if yes .. should already spawned instances' timers change with it?

In the case you want to change each individual clone it depends on when you want this to happen. Right before they are spawned? Or should you be able to change the timer from each spawned instance by some sort of selection. Depending on what you're actually doing inside the Model State you might actually want to move the timer outside of the Model altogether and make it part of the Spawning mechanism instead.

Sorry to bombard you with questions instead of a answer .. but these deliberations are necessary for choosing your plan of action.

K
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et »

Ahh yes. My ignorance shows. :) I have a "use tips" section I am building in the Docs, so you should only have to explain this once.

My case is fairly simple.
One instance of a single object
- globally from an options screen
- in play no
- before it is spawned
- the timer is just putting in a delay before moving to the next state in a repeating cycle.
User avatar
Kjell
Posts: 1929
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:)

In that case it couldn't be much simpler. Just set the value from your options screen using a ZExpression.

Code: Select all

pause.Interval = value;
In case you need any pointers on how to script a option screen ( sliders / buttons etc ), let me know :wink:

K
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et »

Really! I tried a few combinations, imagining long file path contraptions, similar to app.(whatever component) use.

Yes, I would like some pointers on making the screen, thank you. :)

question - I've got an array that is only used in the running appState, so you might think it would be local. Yet, my project would cycle between options,running, and score appStates for as long as the user continues. So if the array is declared in the definitions of running, wouldn't it be "reDimmed" each time the running appState is called, and is that bad?

answering my own question - I would probably be writing in a memory leak, so I won't do it, and make some mention of this situation somewhere in the Docs.

Looking at the demos, there doesn't seem to be an example of an option screen that a user can enter values. This is usually done with GUI controls in programming languages. If you haven't invented a slider or spinner, I can make do with a read in text file.
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et »

Anyone tell me why this doesn't cycle?
Attachments
noCycle.zgeproj
(900 Bytes) Downloaded 520 times
User avatar
VilleK
Site Admin
Posts: 2382
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Change the expression to:

Code: Select all

arrow.Y -= 0.1;
 if(arrow.Y<= -0.9){arrow.Y = -0.4;}
The problem is with floating point inaccuracies that makes things like (1.0 - (0.1*9)) not exactly (but almost) equal 0.1. This is a problem with floating point values in general, not only in ZGE. See for example this page.
User avatar
Kjell
Posts: 1929
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:!:

When dealing with ( traditional ) menu's you always want to use integers instead of floats. Right now your selection variable range is -0.4 to -0.8, while you want this to be 0 to 4. Some benefits to this ..

- Array indices are integers, so this makes it easier to pull data rom arrays.
- By separating your structural data from your visual you're free to do whatever you want visually*
- Using a "standard" like this means that you can write a ZLibrary once, and simply re-use it on any other menu.

*When you'd make your menu behavior dependent on the -0.4 to -0.8 range, as soon as you reposition your menu ( and thus changing the range ) all of your conditions will be broken.

And in order to determine the position of the arrow, you do a additional calculation that converts the 0 to 4 range variable to -0.4 to -0.8.

K
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et »

Ah, yes. Thanks guys.
ZLibrary - good idea - time I investigated that component.
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et »

There's something here I don't understand. I'm just trying to put in a delay before spawning.
Attachments
noSpawn.zip
(962 Bytes) Downloaded 533 times
User avatar
VilleK
Site Admin
Posts: 2382
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

The Timer-component needs to be in an OnUpdate-list. Move it from OnStart to OnUpdate and it will work.
User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et »

Ah yes, thank you. I will make a note of that.
Post Reply