How do I

Get help using Construct 2

Post » Wed Sep 30, 2015 8:52 am

I am trying to get to grips with Construct 2 and was wondering is someone could help me.

What I am trying to do is to get the red sprite to follow a straight path to each black sprite in order (i.e 1, 2, 3,4) and then loop the whole thing again. Any ideas?

http://www.planetserve.com/game/image.png
B
17
S
6
G
1
Posts: 83
Reputation: 1,895

Post » Wed Sep 30, 2015 9:49 am

I made a little example. Hope that will help.
https://drive.google.com/file/d/0B5FlDY ... sp=sharing
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Wed Sep 30, 2015 12:10 pm

That's really clever - thanks. I do have a couple of questions though.

1. How did you setup the instance variable for sprite2 for it to show as <varies>

2. Would the speed of moving sprite vary according to the performance of the target machine?

Thanks.
B
17
S
6
G
1
Posts: 83
Reputation: 1,895

Post » Wed Sep 30, 2015 12:45 pm

1. How did you setup the instance variable for sprite2 for it to show as <varies>

You can set instance variables individual for each by click on the instance in the layout and set it. If you click then in the Objects-Windows of the one object it will show no value (or varies in the add instance variable window), because the instances have different values.

2. Would the speed of moving sprite vary according to the performance of the target machine?

Yes it would, you can prevent this if you use delta time. In this example: 'Move Forward 60*dt'.
This uses delta time 'dt' which is the length between the ticks (normally 1/60 sec for 60 frames per second).
If your game slows down the length between the ticks will grow. So, it will prevent that it will goes slower but it will go choppier. And if it goes to slow you can get problems with collision, because if your sprite does every tick a hop of 20 pixel it can miss the trigger for the collision and go through a wall or enemy.
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Wed Sep 30, 2015 2:34 pm

Wow, I have a lot to learn. The trouble is I like to understand something before moving on.

Why doesn't something like my example work - what am I missing?

http://www.planetserve.com/game/move.capx
B
17
S
6
G
1
Posts: 83
Reputation: 1,895

Post » Wed Sep 30, 2015 3:05 pm

Why doesn't something like my example work - what am I missing?


Because your two events fight against each other.
If there is a collision the first event will still trigger, so the first event rotate the sprite to sprite1 and move 1 pixel and second event rotate the sprite to sprite2 and move 1 pixel at the end nothing will happen.

Here an example that should work:
Code: Select all
System On start of Layout -> Sprite Set angle toward(sprite1.x,sprite1.y)
System Every tick -> Move forward sprite.speed*dt pixels
Sprite On collision with sprite1 ->Sprite Set angle toward(sprite2.x,sprite2.y) 
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Wed Sep 30, 2015 3:18 pm

That makes sense. Thanks for all of your help today.
B
17
S
6
G
1
Posts: 83
Reputation: 1,895

Post » Wed Sep 30, 2015 9:31 pm

How would it be possible to get two or three of these 'programmed' sprites working together on the same layout?
B
17
S
6
G
1
Posts: 83
Reputation: 1,895


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests