How do I replicate a penalty kick

0 favourites
From the Asset Store
You must point the ball correctly to the goal and get points.
  • Hi everyone,

    I am trying to replicate the a penalty kick from this game

    It seems that the ball get some kind of curve and decrease the size slightly by the time it gets to the goal.


  • no idea friend.. waiting for someone to share the code or capx

  • Basically you want to have a random movement first in x axis within a certaing range, which stops after button press, then the same effect in the y axis, once more stopped on button press. Then you have to tie this movement to a slider on screen. I would add it to a variable, both the values.

    Also on key press after the ball is being shot, you need to make a tween movement (the slight curve and decrease in scale) of the ball from the player position to the position of the x,y that remiains after button press, stored in a variable that Ive mentioned above.

  • I get the idea. The problem is to do the movement.

    I started using the behavior moveTo but I can't figure out the curve thing

  • I am thinking about something like this:

  • There is a behaviour called path to spline or something simillar, search the forums, perphaps its what you are looking for.

  • It's not so much a curve, it's just perspective. The simplest kind is x/z and y/z, where z if how far into the screen the ball is.

    Give the Ball sprite some instance variables called "z", "startX" and "startY". Also you presumably you have the two sprites horizontalSlider and verticalSlider. The events below assume the ball is launched as soon as the layout is run and the sliders are already in place. All the numbers are tweakable.

    global number t=0

    ball: on created

    --- set startX to self.x

    --- set startY to self.y

    every tick

    --- set t to min(t+dt, 1)

    --- ball: set z to lerp(1, 10, t)

    --- ball: set x to (lerp(self.startX, horizontalSlider.x, t)-screenwidth/2)/self.z + screenwidth/2

    --- ball: set y to (lerp(self.startY, verticalSlider.y, t)-screenheight/2)/self.z + screenheight/2

    --- ball: set size to (64/self.z, 64/self.z)

  • R0J0hound,

    You solution is nice but it doesn't apply well to the example in question.

    The ball get too small and it doesn't go where it supposed to end.

    I sent you a msg with the capx with what I got so far.

  • Sorry I can't open the capx you sent me. I don't have the moveto behavior installed.

    Edit: I did look at the event sheet xml and it appears you're using a different approach, so I probably won't be much help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • R0J0hound,

    Thanks for your help anyway. I appreciate it.

  • R0J0hound

    Hello is there a way to replicate the same effect with swipe . This demo was created with createjs . Please can you help R0J0hound

  • There probably is. This is a pretty old topic so I'm not familiar with what I did. Also I don't have the patience to load that link to see what it does.

  • See my old example here:

  • Yep this is what I need Thank you alextro it needs some tweaking to get the user to swipe on the ball instead of swiping everywhere and prevent the user from swiping back

    Will start reading your logic and Wow a lot of calculations

  • Perspective viewport is where player need to focus (left corner). Other viewports are use for reference and visualize the logic.

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