A Question on Arrays and Timers

For questions about using Classic.

Post » Fri Mar 20, 2009 2:53 am

Let me say, I am liking Construct more and more.

But I am curious as to know if there is a way to define data to be put into an array (Like, an option to put the info into the object's properties other than the size) or if the data has to be created when running the program (defined in an event sheet; sounds like the same but).

Second, timers. I've looked around for them and wondered how those are used. Even the stuff in the platforming tutorial flew over my head when it used the timers. Like, there are some instances where I'd, say, want something to stop and wait a few seconds.
B
2
G
3
Posts: 13
Reputation: 876

Post » Fri Mar 20, 2009 4:50 am

[quote:rdx54dcc]But I am curious as to know if there is a way to define data to be put into an array (Like, an option to put the info into the object's properties other than the size) or if the data has to be created when running the program (defined in an event sheet; sounds like the same but).[/quote:rdx54dcc]

There are numerous ways you could save data for an array. The Array object even has the ability to save and load the array as a file. Or you could store array data as the default value of an object's private variable. Or in a text object. Or in an INI file, which I recently did based off of David's example of a level editor, for use in my own game.

As for the trouble with timers, if you have any specific questions about the Platform School tutorials feel free to post in that thread. If it's just about timers in general, or the Timer behavior, then this is the right place to post, but I'm afraid you'll have to be more specific with what you're trying to do.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Mar 20, 2009 6:21 am

Timers in general, actually.

At least I think I read it right. You see, when I looked at timers I thought of "Do something after X amount of seconds" timers (Or in this case, milliseconds). That's where I am lost.
In my example and testing, I'm trying to see if I can figure out timers and just get the final result.

(Conditions)
While
"Boxsize" is between 0 and 20
Every 1000 milliseconds

(Actions)
Add 1 to boxsize
Box: Set height to box.x + 13

The effect is to have a box slowly change size from small to large through a course of 20 seconds, but instead I just see the large box.

Also, what I mean is preparing data to be used in an array for the first time. Like, item data (Just now tested to see how arrays are saved and got a whole lot of boxes; seems like they are saved by bits). From the looks of it it looks like I may be better off declaring the data in one big initializing event the first time, then loading the data afterward (saving each time something needs to be modified).
B
2
G
3
Posts: 13
Reputation: 876

Post » Fri Mar 20, 2009 12:27 pm

You could use the Timer Behavior, and set it to repeat until the object is of the size you want; may be a little neater.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Sun Mar 22, 2009 5:52 pm

"While" is a loop condition. Having a "while" with an every x milliseconds doesn't really make sense, since "While" runs as may times as it needs to. In your case "While" is making the box grow right away, in 1 frame, becasue the boxsize is between 0 and 20. get rid of the "while" and it should work.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Sun Mar 22, 2009 6:40 pm

I agree that it's probably something to do with having a While and an Every in the same condition.

Personally, when I want something to grow/shrink/move etc independently, I create a group that updates the object every 'n' m/s, and make the group self-terminate (disable) when it reaches it's target.

So you can enable the group when you want it to happen, and then just leave it to it. :D

Sponge.
B
2
S
1
G
3
Posts: 105
Reputation: 1,310

Post » Mon Mar 23, 2009 5:48 am

I actually figured it out thanks to Rich's suggestion (The timer thing, anyhoo, in the behavior thing).
The result was much easier than I made it out to be initially. As a little bonus I even figured out how to make life bars using only boxes.
Construct does take a bit of getting used to, I admit. And many thanks all who helped me on this!
B
2
G
3
Posts: 13
Reputation: 876


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests