Compare Frames

0 favourites
  • 9 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • I can't get the compare frame event to work, I have a sprite that spawns two instances of a new sprite every 3 seconds and I'd like it to compare the two new instance's frames to check if they are the same. if so, change it

    capx file

    fileswap.com/dl/lEagoxlFE

    Alternatively I'd like to know how this would be best accomplished using families just for my own sake because I've tried it with them as well to no avail

  • people aren't as helpful as they used to be

  • I feel the same way.

    The truth at the end of the day is that nobody cares about your project except for you. This is why every single one of my 'how do I?' threads involves me posting follow-ups stating things I've found as I've tried to diagnose the problem. People probably won't read them, but what drives me to develop is the notion of progress, even if it's just a little progress, and that's why I continue to post.

  • Posting your findings does help others who are following in your footsteps, i know it's helped me in a number of unresolved posts when people post their findings even if its not solved at least there's a little more info to go on.

    Shame though, I thought the community was more active.

  • Centra

    The two issues you are running into are newly created object picking and dealing with picking multiple instances of the same type separately.

    Created objects become the only picked object for the the rest of the event. In the case of event 1 and 2 the 2nd spawned sprite will always have "isanswer" toggled. Also the created object object won't be able to be picked as normal until the next toplevel event (event that isn't a subevent) however a triggered event such as "on created" or a funtion call doesn't count as it's more like it's run right when it's called. Your on created event as it is has only one sprite picked (the new one) which can be somewhat solved by adding a "pick all sprite" system event, but you still won't be able to pick the other spawned sprite until the next toplevel event.

    And that leads nicely into issue #2, picking multiple instances of the same type separately. There are two ways to deal with this:

    * The first way is to pick one of the instances and save the values you want to compare into local variables and then pick the 2nd and do the comparison. It would look something like this:

    + Some event that picks two sprites
    ---local number inst0frame=0
    ---+pick sprite instance 0
    ------ set inst0frame to sprite.frame
    ---+pick sprite instance 1
    ---+compare inst0frame = sprite.frame
    ------ do something

    * The second way is to use single object type family. So you can pick two objects of the same type separately using two different names. You can think of the family name as an alias to the object name. Events would look something like this:

    + Some event that picks two sprites
    ---+pick family1 with uid of sprite.uid
    ---+pick family1 instance 0
    ---+pick sprite instance 1
    ---+compare family1.frame = sprite.frame
    ------ do something

    Ok, and in respect to what you're trying to do you can simplify it by putting the sprite into a family and call it say family1.

     +every 3 seconds
    ---create sprite
    ---set sprite frame to random
    ---create family1
    ---set family1 frame to random
    --- +while
    --- +compare sprite.frame = family1.frame
    -------set family1 frame to random

    cheers

  • Thank you very much, I appreciate you going the extra mile to explain how picking instances are handled. Following your example at the end, still giving me problems though.

    <img src="http://i42.tinypic.com/2wqcy9v.png" border="0" />

  • <img src="http://i43.tinypic.com/kei1cp.png" border="0" />

    this one doesn't give a runtime error but it doesn't prevent duplicates either

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • My main problem seems to be 'some event that picks two sprites'

  • <img src="http://i43.tinypic.com/2n6vg29.png" border="0" />

    Finally got it to run without duplicates, debugging display for frames doesn't work though

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)