How do I create a chain for a dog.

Get help using Construct 2

Post » Thu May 22, 2014 4:48 am

I have a dog sprite that has a bullet behavior on it and he runs right and left...now I want a chain to extend out
and follow the dog...

Now a friend suggested that I use a tiled background and I am and in my event sheet I have every 5 sec, set width of dogchain.x +32... something like that...

is there a way to set two pivot points on my tiled background image...one to pin to the dog house and one to pin on the dog..and have it automatically stretch in and out depending on the pos of the dog?
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Thu May 22, 2014 5:12 am

You could use a small sprite, place it at the center of where you want the chain to originate, than every tick, set angle towards dog, and set the width to distance(chain.x, chain.y, dog.x, dog.y) That could give you the effect you are looking for if I understand you correctly.
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

Post » Thu May 22, 2014 5:33 am

chainTiled.X, chaintiled.y, dog.x,dog.y

this is what I put down for the Set width to distance and I get an error, something about the syntax.
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Thu May 22, 2014 5:39 am

Could you post your capx than I might take a look and see where the error is.
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

Post » Thu May 22, 2014 5:46 am

dog chain code is in Event sheet 1 at the very bottom.

http://www.dwbailey.com/images/dogchain.capx
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Thu May 22, 2014 7:56 am

Ok I've taken a look at your capx, haha but it was quite cluttered so I am a bit lost, sorry. But I get an idea of what you are trying to do, so I've created a simple capx that should help you understand and implement into your game. Just two important things though, I used a sprite in the example, but you can still use a tiled background. If you do use a sprite, remember to set the image point for the chain to the left or right and not the middle.

https://www.dropbox.com/s/hz5n91gg4la9fgp/DogAndChainExample.capx
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

Post » Thu May 22, 2014 1:12 pm

thanks a lot for doing that for me. I still need to understand expressions and how to use them. I noticed in your math you put distance in there..i didnt even put it there when i tried it.

anyway got it to work..i tried it using tile background but got bad results because you can put image points in a tile background, so the start point was all wierd.

everything looks good except the stretching that i get.
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Thu May 22, 2014 1:52 pm

Ill stick with it stretching like that. when the dog moves back and forth i tried to make it like he is being pulled back from the chain anyway. So the stretching helps sell the idea.

still would be nice to know how to fix that if possible for future ref.
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Thu May 22, 2014 3:29 pm

Glad to know it's helped solved your problem.

I think you could still use tiled backgrounds. In the left properties bar, in the hotspot section, make sure it is set to top left. It might not be as perfect as using sprite with its image point option, but it could still work. If you add some clever objects on top to hide the main hotspot where the chain turns, you could still get nice results.

I've created a new example with what I mean, so hopefully you might still be able to use tiled backgrounds.

https://www.dropbox.com/s/y412q5jehlplxpg/DogAndChainExample2.capx
B
46
S
23
G
31
Posts: 693
Reputation: 20,637

Post » Fri May 23, 2014 1:17 pm

thanks for that 2nd example. i still need to tweak mine, I never new about the hotspot. I really wish there was a Expressions thread that did several examples for each one.
B
9
S
2
Posts: 272
Reputation: 1,632


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests