[solved] Name tag position problem

0 favourites
  • 11 posts
  • Hi, I have the following problem.

    I've go an unspecific amount of hero objects in a "Heroes" Family.

    I randomly create an unspecific amount of heroes, neatly standing in a line.

    All good so far.

    Every time a Hero is created, a nametag is created for that hero.

    That name tag is then pinned and positioned to the hero just created.

    The pinning works nicely. When I move a hero by mouse down, the name folows nicely.

    BUT! When the nametag is created it doesn't position itself correctly at heroes imagepoint 1.

    When created, the first nametag appears about x + 100, y + 100 from the hero, the second about x + 200, y + 200 , the third about x + 300, y + 300 , and so on. The numbers are just an aprox-guess and are there to give you an idea of my problem. (but might have something to do with the way I create the heroes, see below...)

    I assume I do something wrong but cannot understand what...

    Example with 3 heroes:

    +System -> On start of layout

    System -> Create object Heroes on layer 0 at (LayoutCenter.X -100, LayoutCenter.Y -100)

    System -> Create object Heroes on layer 0 at (Heroes.X + 60,Heroes.Y)

    System -> Create object Heroes on layer 0 at (Heroes.X + 60,Heroes.Y)

    +Heroes -> On created

    System -> Create object txtName on layer 1 (Heroes.X, Heroes.Y)

    txtName -> Pin Pin to Heroes(Position & angle)

    txtName -> Set position to Heroes(image point 1)

    Works fine, but the position is wrong for some reason...

  • Kind of difficult to tell without a capx to poke around in, have you tried skipping the positioning of the text after pinning by creating the text at the image point?

    Create object txtName on layer 1 (heroes.ImagePointX(ImagePoint), heroes.ImagePointY(ImagePoint))

    Edit: Also, if you have more than one frame, make sure the image point on the other frames is at the right spot, they can move frame to frame. Right click the image point in the Image Points window and select "Apply to whole animation"

  • No frames, just a plain image.

    Still experimenting with basics...

    I'd be thrilled to share the capx on the forum, if I knew how to share it here? Link to some ftp server?

  • Try if this will position them properly

    +System -> On start of layout

    System -> Create object Heroes on layer 0 at (LayoutCenter.X -100, LayoutCenter.Y -100)

    System -> Create object txtName on layer 1 (Heroes.X, Heroes.Y)

    txtName -> Pin Pin to Heroes(Position & angle)

    txtName -> Set position to Heroes(image point 1)

    System -> Create object Heroes on layer 0 at (Heroes.X + 60,Heroes.Y)

    System -> Create object txtName on layer 1 (Heroes.X, Heroes.Y)

    txtName -> Pin Pin to Heroes(Position & angle)

    txtName -> Set position to Heroes(image point 1)

    System -> Create object Heroes on layer 0 at (Heroes.X + 60,Heroes.Y)

    System -> Create object txtName on layer 1 (Heroes.X, Heroes.Y)

    txtName -> Pin Pin to Heroes(Position & angle)

    txtName -> Set position to Heroes(image point 1)

    Basically create hero first and right after that create txtName.

    If that works (which it should!) it means you got something wrong with your events

    edit: just noticed, you dont need to set it like that

    System -> Create object txtName on layer 1 (Heroes.X, Heroes.Y)

    txtName -> Pin Pin to Heroes(Position & angle)

    txtName -> Set position to Heroes(image point 1)

    There's no need to set position twice, instead you can use:

    System -> Create object txtName on layer 1 (Heroes.ImagePointX(ImagePoint), Heroes.ImagePointY(ImagePoint))

    txtName -> Pin Pin to Heroes(Position & angle)

  • The first suggestion was the one I started with in the first place. It didnt work, as all seemed to pin to first hero. I can try it again, but Im quite sure I didnt work the first time.

    The extra position is unnecessary, I know, but it was there to show that I try to enforce the position in several ways without success.

    Ill try suggestion 1 again, and then Ill just try to maybe move the text to hero and then pin...

    Ill let you know how it went....

    Btw, if I wanted to share the capx on the forum, how would I do that?

  • Use Dropbox , it's free !

  • I must apologize for my earlier message, that on a second reading might have sounded a bit arrongant. I hope I didnt offend...

    I tested, again, writing the creation code after each Hero creation.

    I must have had some other problem earlier, as I remeber the effect to be totally different. Now, the result was identical, that is, the nametag is positioned wrongly...

    BUT, re-reading closely your answer part 2 , the one I arrogantly tossed aside earlier, I noticed that you suggested creating the text using the heroes imagepoint xy instead of the heroes xy.

    AND THAT DID THE TRICK! \o/

    My understanding of why and how, and how it differs from what I did earlier is far beyond me. But I'm happy, and that is what counts.

    To share my happiness, I'll just share my capx with everybody.

    It doesn't contain any rocket sience, but there is a nice example of drag and drop done with events and the dynamic hero creation(very simple)

    dropbox.com/s/fnecrxap6gxqpqa/CutthroatCaverns.capx

    (Thanks to Whiteclaws)

    (Hope this works. First time Dropbox user. Would make it a h-link but too low rep..)

    If I may, one more quick question...

    When I pile all the heroes on top of each other and drag and drop, it drags and drops all of them. A nice effect, but one I do not want...

    I heard that there is a "just once" event modifier or similar , but can't find it. And if I found it, would it help?

    Alternative solution: prevent heroes from piling...

    What is the easiest way to do it? Creating a colision event or is there a ready made behaviour that would make me even more happy?

  • Adding the following condition to the Left Mouse click event should fix the multiple selection issue.

    Heroes -> Pick Top Instance

    (Under Z Order - pick top/bottom)

  • There are no Pick options in Zorder at all?

    Just "Move to top", "Move to bottom", and "Move to layer".

    Something wrong with my Construct?

    Im also going nuts when trying to find "Set CSS style" for textboxes - I cannot find that action at all

  • Ah sorry.

    Additional condition.

    Found it.

    Thanks.

    Tried to do it as an action...

    Still having problems with finding the Set CSS... cant find it in actions as the Manual claims... Is it too somewhere else?

    <-Edit->

    Found Set CSS...

    But only in System -> Start of layout.

    Didnt find it in for example txtText -> On Created

    or

    Mouse -> Cursor is over txtText

    Which makes it close to useless in my opitnion...

    I would initially want to set a style of Text objects to a CSS style, change them to another when the cursor is over them and back to original when cursor is off.

    There seems to be no way of doing that other by not using css...

    Am I right (hope not...)?

    <-Edit->

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Since the subject of this thread has completely changed from the original, I'm ending this thread here and taking my CSS related question to a new topic.

    Thank you everybody for helping me.

    You are the Best!

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