[solved] Name tag position problem

Get help using Construct 2

Post » Fri Feb 01, 2013 4:44 pm

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

Tumba2013-02-03 04:25:00
B
5
S
1
Posts: 18
Reputation: 436

Post » Fri Feb 01, 2013 5:18 pm

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"Paradox2013-02-01 17:22:25
B
200
S
51
G
30
Posts: 896
Reputation: 36,494

Post » Fri Feb 01, 2013 8:32 pm

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?Tumba2013-02-01 20:33:32
B
5
S
1
Posts: 18
Reputation: 436

Post » Fri Feb 01, 2013 8:49 pm

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)shinkan2013-02-01 20:52:16
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Sat Feb 02, 2013 1:13 pm

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?

B
5
S
1
Posts: 18
Reputation: 436

Post » Sat Feb 02, 2013 1:28 pm

Use Dropbox , it's free !
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sat Feb 02, 2013 4:46 pm

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)


https://www.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?

Tumba2013-02-02 16:51:17
B
5
S
1
Posts: 18
Reputation: 436

Post » Sat Feb 02, 2013 6:15 pm

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)

BenGIJOE2013-02-02 18:16:30
B
5
S
1
G
1
Posts: 12
Reputation: 899

Post » Sat Feb 02, 2013 6:33 pm

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

B
5
S
1
Posts: 18
Reputation: 436

Post » Sat Feb 02, 2013 6:43 pm

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

Tumba2013-02-02 19:13:47
B
5
S
1
Posts: 18
Reputation: 436

Next

Return to How do I....?

Who is online

Users browsing this forum: Khamsou, nedzad and 20 guests