How do I

0 favourites
  • 8 posts
  • 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

  • I made a little example. Hope that will help.

    https://drive.google.com/file/d/0B5FlDY ... sp=sharing

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • [quote:wxp0l1kx]

    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.

    [quote:wxp0l1kx]

    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.

  • 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

  • [quote:1w5iiw1w]

    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:

    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)  
    [/code:1w5iiw1w]
  • That makes sense. Thanks for all of your help today.

  • How would it be possible to get two or three of these 'programmed' sprites working together on the same layout?

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