While THIS happens DO that?

0 favourites
  • 10 posts
  • I'm in the process of making my game on Construct.

    See the game in action (Flash)

    I'm able to drop a ball each time I click.

    But I don't know how to:

      > Stop the click event while the ball is moving. > Kill the ball one second after it stopped moving.

    Note: I'm using Physics.

    This is what I have so far:

    <img src="http://img7.imageshack.us/img7/3944/constructw.png" border="0">

  • Hi Ionrot,

    Take a look at this capx I made for you.

    it will show you how to :

    Stop the click event while the ball is moving.

    Kill the ball one second after it stopped moving.

    Lucky Hit capx

    Just a quick and dirty capx to show you how it works.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Great Maxum! I have one question.

    When Ball.X and Ball.Y match 0, they become oldX and oldY, right? How this have to do with the current speed of the ball? To my understanding zero would be a location in X and Y axis, which is the top left corner, and not a value of movement. <img src="smileys/smiley24.gif" border="0" align="middle" />

    Thanks again, I hope you can clear this up for me. <img src="smileys/smiley3.gif" border="0" align="middle" />

  • In maxum's capx, he stores every tick the position of the ball, at the end of the event sheet. So if at the next tick, the position of the ball is the same (ie : the ball doesn't move anymore) oldX and oldY will equal actual X and Y position. He use these condition to check if the ball stopped.

    But there's an easier way to do that

    System: Ball.Physics.VelocityX = 0
    System: Ball.Physics.VelocityY = 0
        -> Ball: Destroy
        -> System : set OKToDrop = 1[/code:14mmb2q5]
    Also, while I'm at it, I would say that the OKToDrop variable is useless, you just have to check the Ball.Count value (which returns how many ball there's on the scene)
    Also he could replace event 2 by
    [code:14mmb2q5]System: Every tick
        -> Balldroper: Set X to Clamp(Mouse.X,25,300)
        -> Balldroper: Set Y to 18[/code:14mmb2q5]
    
    Well in short that would look like that
    [url=https://app.box.com/s/q7tkryhuc3m2arf34htv]maxumsEnhancedLuckyHit.capx[/url]
  • Thanks Yann for your input on this. As always you have a more elegant and efficient way to solve these problems.

    Have a merry Christmas and a happy new year.

  • the problem ive got with velocity x velocity y is they work only on the x y axis, what about something that is moving in cross motion, the only solution i could think is having some distancevelocity

  • This game seems cool :)

    Let us know when you've the final version :)

  • vtrix:

    VelocityX and VelocityY are vector components, every movement can be broken up into 2 axial displacements.

    <img src="http://dl.dropbox.com/u/23551572/C2/vectorMovement.png" border="0" />

    For instance if VelocityX = VelocityY and they aren't equal 0, the object moves diagonally.

  • Thanks Yann, velocity makes more sense to me, and it's easier to read.

    Is there a way to add an ELSE / OR statement bellow VelocityX and Y conditions? I can make a separate function, but it would be nice to see a cleaner code. The ELSE statement is intended to kill the ball if it goes away from the stage (stage width 300px, stage height 600px)

  • There is no ELSE statement as it is, but you can use the regular events.

    In our case,

    ball.x < 0 //Left boundary

    ... Ball => Destroy

    ball.x > 300 //Right boundary, you can also use "layoutwidth" or "windowwidth"

    ... Ball => Destroy

    ball.y < 0 //Top boundary

    ... Ball => Destroy

    ball.y > 600 //Bottom boundary, you can also use "layoutheight" or "windowheight"

    ... Ball => Destroy

    This way, if the ball is out of boundaries, we destroy it.

    Layoutheight/layoutwidth and windowwidth/windowheight are system expressions.

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