linkman2004's Recent Forum Activity

  • I'd suggest taking a look at the manual page for the function object. In the dialog box that appears when you add the Call function action there's a button labeled Add parameter that will add a field to pass a parameter. It appears that you can add as many as you want. You can then access these parameters by getting the param expression while passing in the zero-based index of the parameter you want.

  • Time for a physics lesson! The path that the arrow will follow is going to be a system of two equations, which we'll derive. From some basic trigonometry(and intuitive thinking), we know that the system of equations describing the motion of an arrow without gravity is:

    x(t) = x0 - cos(a) * s * t
    y(t) = y0 - sin(a) * s * t[/code:o2e19sw6]
    
    Where x0 is the initial x position, y0 is the initial y position, s is the starting speed of the arrow, a is the angle the arrow makes with the X-axis, and t is the time -- in this case, in seconds.  Since gravity is a factor as well, we need to take this into account as well.  For an object that is merely falling from gravity, our equation for y is derived from acceleration due to gravity using calculus:
    
    [code:o2e19sw6]ay(t) = g => ay'(t) = vy(t) = g * t => vy'(t) = y(t) = 0.5 * g * t^2[/code:o2e19sw6]
    Where ay(t) is acceleration on the Y-axis, vy is the velocity on the Y-axis, g is acceleration due to gravity(a constant), and ' denotes a derivative of the preceding function identifier.
    
    We can now add this to our initial system -- or rather, just y(t), since x(t) isn't affected by gravity -- to yield the system:
    
    [code:o2e19sw6]x(t) = x0 - cos(a) * s * t
    y(t) = y0 - sin(a) * s * t + 0.5 * g * t^2[/code:o2e19sw6]
    You can now figure out the position of the arrow at any point in time, so you could use a for loop -- for example, from 1 to 10, dividing the index by 10 to yield a time range of 0.1 to 1 seconds -- and generate dots representing the future position of the arrow at certain points in time.
    
    In your case, g will be your arrow's gravity in pixels per second, and s will be the predicted speed of the arrow -- based on how far back it's pulled -- in pixels per second.
    
    This should give you everything you need to implement such a system.  I'll post an example later, but if you get it figured out before then, go ahead and post it so others can benefit.
  • Here's one solution using some basic trigonometry:

    [attachment=0:r02llomo][/attachment:r02llomo]

  • This will work where your angle is coming from the angle expression. Where X is your angle and -180 <= X <= 180, using a conditional expression.

    NiceAngle = X > 0 ? X : 360 + X[/code:3d1hpa1g]
    Which translates equivalently to the statement(not usable, this is just for demonstration purposes):
    
    [code:3d1hpa1g]NiceAngle = X if X > 0 else (360 + X)[/code:3d1hpa1g]
  • Unless I'm mistaken the event search feature only searches the active event sheet, which makes it less than useful when following code organization practices such as including multiple event sheets.

    Granted, but I was suggesting it as more of a helpful tool -- it's still preferable to looking through event sheets manually for references to objects.

  • Unfortunately, reliably finding unused code(Construct or otherwise) is a difficult problem without a general solution, as to catch everything you would have to test all possible input combinations, which is unfeasible.

    What I suggest is to adopt solid code organization practices. For example, making extensive use of the function object. This allows for code reuse and good logical encapsulation. In addition, it's much easier to find if code in a function is being executed, as you merely have to check if the function is being called from anywhere -- there's no automatic way(as far as I'm aware) to check this, but it's much easier to check manually than without the use of functions.

    Additionally, making smart use of groups is an excellent way to group code that is logically related. By keeping related code together physically, it's much easier to see if a piece code has been replaced, made redundant, etc. Strewing logically related components through a large event sheet is going to lead to confusion and make the project harder to extend in general.

    As for checking for unused objects, the pay version of Construct 2 has an event search feature which you could use to search for references to objects, which would greatly help in determining which objects are being used.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I whipped up a quick example showing how to achieve this type of scrolling. It's implemented in a generic manner to make it easy to change how much padding you want on any of the four sides of the character.

    [attachment=0:1u81g0w6][/attachment:1u81g0w6]

    EDIT: Note that this only shows how to do active area scrolling - there may be additional work required to get this playing well with zone scrolling.

  • I'll take it this capx isn't your own and is just illustrating what you want to achieve? You need to set Unbounded scrolling to Yes in your layout properties.

  • Check the length of the text in the text box, and truncate it if over 20. Example:

    Compare two values: len(TextBox.Text) > 20          TextBox Set text to left(TextBox.Text, 20)[/code:29l9bkyk]
    [i]left(s, x)[/i] returns a string containing [i]x[/i] characters starting from the left side of the string [i]s[/i].
    
    EDIT: Ah, got beaten to it, but there it is.
  • Try updating your graphics drivers - this is more than likely caused by your specific system configuration.

  • You can do it like this:

    Compare two values:
    
    foo = "foobar" | foo = "footaro" | foo = "fooji"
    
    equal to
    
    1(True)[/code:qddidw3o]
  • Use For each(ordered) to loop through the objects in your family, set the expression to Family.Y(Replace Family with whatever your family name is), order by ascending, and then add an action to send the current family object to the front. This will send each of your family objects to the front in turn, starting from the object with the lowest Y value, resulting in the ordering you want.

linkman2004's avatar

linkman2004

Member since 15 Jan, 2008

Twitter
linkman2004 has 1 followers

Trophy Case

  • 16-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

18/44
How to earn trophies