Family member location

0 favourites
  • 6 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Noob question...

    I have a feeling that the answer to this one is simple, I'm just not able to grasp it at the moment...

    I have a simple layout with sprites of family "Heroes" created on a tiled background covering the center of the window leaving the sides bare.

    What I want:

    When a hero - sprite is dragged and dropped outside of the tiled background the dragged sprites boolean "Selected" should turn to true.

    When a hero - sprite is dragged and dropped inside of the tiled background the dragged sprites boolean "Selected" should turn to false.

    What I have:

    When a hero - sprite is dragged and dropped outside of the tiled background, all Heroes boolean "Selected" turns to true.

    When a hero - sprite is dragged and dropped inside of the tiled background, all Heroes boolean "Selected" turns to false.

    I cannot refer to a specific sprite object as all the sprites are generated randomly from the Sprites in "Heroes" family.

    I assume that this might even be solved by placing the action inside the correct event. I tried with several possibilities, but alas, fail every time...

    Please, what is wrong?

    Link to my CAPX:

    dropbox.com/s/fnecrxap6gxqpqa/CutthroatCaverns.capx

    The fun happens on the Village layout. Ignore the rest...

    This CAPX has a pretty nice Debug system that shows the UID of the sprites and the "Selected" boolean value when it changes.

    So experimenting should be easy...

  • It does work, problem is in your debug text :)

    Update texts in separate events like this:

    Every tick

    .. For each xtxtCharDebug

    .. Pick nearest Hero

    ..... Set text to 'Selected: ' & Heroes.Selected

    You were updating the texts without picking a hero, so they were updating the status of the first created hero by default :)

  • Ok, that probably works.

    I tried originally to incorporate the action into the on mouse left button released, as it neatly knows which hero to assign the text Objects to. But it updated just once and then all heroes.

    Could the effect be achieved some other way, maybe related to the mouse left button released?

    Every tick, souds a bit overkill, as the purpose is just to see which heroes are selected in the start of the game.

    After that the selection area will disappear and not be used any more...

    Also I'm a bit worried of "pick nearest" as heroes can, theoretically at least, overlap each other...

    <-edit-> I do assign the hero UID to every object related to the hero, so I'll probably manage to cook up something<-edit->

    If you have another idea I'll be happy to hear it, if not, I'm happy already. Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Every tick, souds a bit overkill, as the purpose is just to see which heroes are selected in the start of the game.

    After that the selection area will disappear and not be used any more...

    Also I'm a bit worried of "pick nearest" as heroes can, theoretically at least, overlap each other...

    <-edit-> I do assign the hero UID to every object related to the hero, so I'll probably manage to cook up something<-edit->

    If you have another idea I'll be happy to hear it, if not, I'm happy already. Thanks!

    You should not be too afraid of 'every tick', performance wise it is trivial.

    Instead of pick nearest you can use 'pick by unique id' and use the UID in the object to pick the host hero, it is cleaner solution every way.

  • Thank you for your help.

    I'm still a bit shy of using every tick, as I will be wanting to show different thing at different times in the txtCharDeBug.

    I solved it the other way around. When creating the hero and txt fields belonging, I assign a id variable to the hero for each object attached to it.

    Thus, in this case, the hero will have the uid of the txtCharDeBug in its txtCharDeBugId variable.

    This allows me to "pick by id" the fields I want when the hero is triggered, instead of monitoring each field each tick.

    Oh, how I'd low to "pick [txtCharDeBug] pinned to Heroes" when f.ex. looping the Heroes... Would save tons of work, but alas....

    Anyway, could not have solved it without your help.

    Thank you very much!

    Consider this case solved.

  • Oh, how I'd low to "pick [txtCharDeBug] pinned to Heroes" when f.ex. looping the Heroes... Would save tons of work, but alas....

    I'd recommend you take a look at containers, they should simplify your loops. If you add hero and all pinned objects to same container then picking the hero picks all the container objects as well. Don't quote me on this though, might recall it all wrong.

    Glad I could help :)

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