0 Favourites

picking technique(too much processing?)

This forum is currently in read-only mode.
  • 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

  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • is there any good way to do such a thing?

    Private variables don't correspond to an ordered indexed list of objects

    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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Pick All / Create Bug
56 1,826
Prominent's avatar
Prominent
Topic
22 895
hellwalker's avatar
hellwalker
Unread hot topic
29 1,734
Velojet's avatar
Velojet