Glue an object to animated image points / image origins?

Get help using Construct 2

Post » Sat Mar 01, 2014 7:14 pm

Hello everybody,

When my character is on RUN animation, his head is bumping up and down.
So I've created a new Image Origin and put it on his forehead on every frame.

Since I'm new to C2 I would love to see an example file or video?
I'm trying to do something like this:
EDIT: The link to the youtube video removed because I'm newbie at the forums.
Search on YouTube for: "Construct 2 Tutorial- Image Origins" and you'll see what I mean on the 29 seconds of the video.

A step-by-step explanation from the beginning, will be very helpful.
Thanks ahead!

* Sorry about my bad English.
B
10
S
1
G
1
Posts: 40
Reputation: 755

Post » Sat Mar 01, 2014 7:56 pm

I have linked an image of my example below. My example 'glues' a player shadow underneath the player sprite at an image point called "Shadow".
Let's go through it step by step. First you want to start by creating an event that runs every tick (so basically the refresh rate of the screen the game is being played on). Then, under a new action, select the sprite that you want to be glued to something, then go to 'Set Position'. Once the dialog appears for the X and Y values, enter in:
For the X coordinate: SpriteToBeStuckTo.ImagePointX("ImagePointName")
For the Y coordinate: SpriteToBeStuckTo.ImagePointY("ImagePointName")

Image

Hope this helps!
B
9
S
3
G
1
Posts: 53
Reputation: 1,296

Post » Sat Mar 01, 2014 8:17 pm

Thank you galacticfan!
Your explanation is very good, I did exactly what you've explained and it works, but the problem is that there is a delay... so when my character is running (it's not so fast, just a bit slower than the default speed) the helmet/hat is following him...

So I guess the "Every tick" is not like: "Always" if there is such thing in C2, I have no idea.

Maybe there is a similar solution using the Pin behaviour? but I'm not sure how to accomplish this exactly.

Is it possible to use the Pin behaviour to imagePoint X+Y ?

Thanks ahead!


EDIT:
Working! I just added a pin action after and it works now!
B
10
S
1
G
1
Posts: 40
Reputation: 755

Post » Sat Mar 01, 2014 8:29 pm

I've created a global number "headVariable = 0"
and when the player touch the hat/helmet headVariable = 1 and destroy the hat/helmet (there are 2, one out of the layout which will change the position) and one that is for collide and collect.

So... when I moved the "Every tick" event as a sub-event when headVariable = 1
it's working on the X only, the bumping head on the Y won't affect it.

Any idea what I did wrong, or how I make it work when the headVariable = 1 ?
B
10
S
1
G
1
Posts: 40
Reputation: 755

Post » Sat Mar 01, 2014 8:33 pm

Yes, another solution is to use the pin behaviour, it will do exactly the same thing :P

You'd have to upload a .capx file for me to see to understand better what is happening. You can do that by going to file and then 'Save as Single File'. From there you should be able to upload it somewhere (a public dropbox link would work) and then post the link.
B
9
S
3
G
1
Posts: 53
Reputation: 1,296

Post » Sat Mar 01, 2014 8:53 pm

Cool, I'm not allowed to post links yet since I'm still a noob around the forums...

So I will try to send you the file via PM?

EDIT:
I guess I'm not allowed to PM either... hehe

How can I send you the .capx file?
B
10
S
1
G
1
Posts: 40
Reputation: 755


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests