How do I correctly use this expression

0 favourites
  • 7 posts
From the Asset Store
Add this awesome sound effects to make your visual novel come to life!
  • Hello all,

    I'm trying to move a number of objects off the screen. I can do this by:-

    Every tick -> Set Y -> Self.Y+1

    The above works exactly as I want. The object moves down and off the screen. Except it keeps moving forever, obviously. So, I thought I would try:-

    Every tick -> Set Y -> Self.Y = 490 | self.Y < 490 ? Self.Y+0 : self.Y + 1

    However, that does nothing. I have looked in the manual (which is where I got the idea for the expression). Could someone please advise where I'm going wrong. thanks.

  • Ok - I have figured out what I was doing wrong:-

    Every tick -> Set Y -> Self.Y = 490 ? Self.Y+0 : self.Y+1

    It's works well, but is it good practise?

  • You don't say, but I am guessing you want to destroy the object when it is outside of layout?

    Here is one way:

  • what do u want to do with that?

  • It is one way.

    But indeed you can use some behavior.

    Or simply use the "Is on screen" condition of an object. As long as it is true, you move it down.

    The moment the object is out of the screen it won't be moved anymore.

    To apply a movement you can also add the bullet behavior, this way you don't need code (apart some code to mention that once out of the screen you want the object to stop moving, have the bullet speed set to 0).

    You can find about all this in the manual as well.

  • I would not use "Every tick: something.Y+1", it will heavily depend on frame rate and if your game runs at 30 fps for one player and 60 fps for the other, it is 100% faster for the second player compared to the first player.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the responses.

    I want to smoothly slide elements (text, buttons sprites, etc...) on and off the screen. It's for a side menu I'm creating. It works pretty well (now that I have sorted out the logic). I was just wondering if it is the most efficient way to do it.

    Kyatric - I will have a look at the bullet behavior - thanks for the tip.

    mindfaQ - I was worried about the fps response, but this is not a game I'm making (it's a simple MP4 video player), the response is great (on a pc anyway - I have not tested it on my windows tablet or android phone ..... yet).

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