picking technique(too much processing?)

For questions about using Classic.

Post » Wed Apr 15, 2009 1:47 am

I don't know much about how events work from a behind the scenes standpoint, so I have a question about how much cpu time I am or am not wasting doing something a certain way

so let's say I had a 1 dimensional array of objects in c++
and I decide I want to do something with some arbitrary object (let's say..the 24th object) in the array
I can just say my_array(23) - do whatever

now in construct, I can create an 'array' of objects using a loop that creates one object per iteration, sets a private variable in that object(let's call it "index") to the loop counter value, and every object gets a unique ordered index

then later I can pick any object directly by having an event with the condition
sprite.value('index') = 23

works fine, easy, wonderful
my question is, from a processing standpoint, is this like c++, pretty much direct
where one object has this index, so it triggers this event

or,
am I basically making the exe loop through every object and check the value of "index",
so if I have 100 objects, I'm making it do 100 steps instead of 1?


i suppose for one group of objects it shouldn't make or break anything,
but for the project I'm working on, there are going to be quite a few picks like this going on
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Wed Apr 15, 2009 2:52 pm

Private variables don't correspond to an ordered indexed list of objects; that'd be pretty impossible to do. It'll be looping the entire list to check which matches it.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Wed Apr 15, 2009 3:09 pm

is there any good way to do such a thing?
[quote="Rich":17oxhvwo]Private variables don't correspond to an ordered indexed list of objects[/quote:17oxhvwo]
is there an ordered indexed list of objects somewhere? like if i keep track of what order they are created, can i pick them by index? ooooh! i just thought of a cool idea that might work for this particular need. let me know if you see any holes. basically i had a hundred or so sprites ordered in a certain way, and i wanted the last one dragged to remain pickable indefinitely, so i could do operations on all sprites, or pick a group, but still go back and that selection could be used as needed for all future actions until another was dragged. i could make a single object of some type called "picker", and then use the object pairer, and use an event to pick picker everytime i need the other thing. neat. still though, i can see other times when being able to single out a pick like i was trying woukd be useful, is it possible to do in a nonwasteful way?

thanks rich for the response
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests