linkman2004's Forum Posts

  • Objects have a count property that returns the number of that object that currently exist. So something like this is what you want

    banana.count < 4 and key pressed, create banana[/code:11bce29n]
  • The issue with your layer not becoming visible is due to a problem with your events in "EsControl". When you click the button and "uionoff" equals zero, you make the "ui" layer visible and set "uionoff" to one. You're then going to the subevent where "uinoff" is now equal to one, and you end up undoing what you just did. Instead, you should do something like the following:

    (Top event)Button4: On clicked
    ----(Sub event)uionoff = 0 then set layer "ui" visibile, set "uionoff" to 1
    ----(Sub event)ELSE, uionoff = 1 then set layer "ui" invisible, set "uionoff" to 0[/code:cnmhrl64]
    For choosing what to put on a layout, it's best to keep things grouped as you would see them in the game.  Generally, I would suggest having menus and game levels on separate layouts -- I would only suggest placing the UI on a separate layout with a global layer if you have multiple game level layouts, otherwise you should simply have the UI layer on your game level layout.  Things like controls, AI, etc -- purely logical portions of the game -- would be kept in separate event sheets, and the sheets you're using would then be included into the event sheets for the layouts that use those logical elements.
    
    I would never recommend using only one layout, as this would get incredibly messy.  The only reason most tutorials have a single layout is because they're mostly demonstrating simple concepts that don't require a separation of elements.
  • "On tap" is a trigger, as indicated by the green arrow next to it. "On function" is also a trigger, and Construct 2 only allows one trigger per event(including subevents), which is why you can't use "On tap" in a function. Instead, your "On tap" event should call your window creation function.

    In relation to your second post, calling a function will return to the branch point after the function has completed -- I'm not sure what gave you the impression that it won't. If you're having issues, I'd suggest posting a capx so someone can help you out with the problem.

  • In the layer properties for the layer that has your objects with the blend modes, you need to turn on "Force own texture".

  • It says in the error message - you have triggers(collisions, on animation finished) as subevents to a loop(for each BeadSnake), which isn't allowed. The green arrow to the left of a condition indicates that the condition is a trigger -- something that's true for one frame when a state is attained and is then false until the state is reversed and once again attained, more or less. Construct 2 treats triggers differently from regular conditions.

    Your use of explicit for each loops here is unnecessary, as all of these conditions will implicitly run against all instances of BeadSnake/bead. Getting rid of them -- although the first one would be the only one causing the error -- should get rid of your problem and still result in everything working the way you'd expect.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Rhindon - PM me your CAPX or one recreating the problem -- ideal, as I don't have the full version of C2 -- and I'll take a look.

  • You could try something like this by saving your object position in instance variables:

    Start of layout
        Sprite.OldX = Sprite.X
        Sprite.OldY = Sprite.Y
    
    Compare two values: distance(Sprite.X, Sprite.Y, Sprite.OldX, Sprite.OldY) >= X
        Do something
        Sprite.OldX = Sprite.X
        Sprite.OldY = Sprite.Y[/code:2t5n08eg]
  • Rhindon - Set the scale rate of your HUD layer to 0 in the layer properties panel.

  • Yes, under the System object there is an "On load complete" event that will trigger once loading is completed.

  • The "Compare selection" events are running all the time because they're simply running a comparison. There are two solutions to get what you're wanting.

    1. Add "On selection changed" events(note that this event is a trigger) for each of your lists, then make your existing events -- the "Compare selection" ones -- subevents to the relevant "On selection changed" event. This will make it so that you're only comparing which item is selected when the selected item for the associated list is changed.

    2. Add "Trigger once while true" to each of your current events. This will make each event run only when the condition has changed from false to true.

  • Putting it after the load action probably wouldn't work, no. The system object has a trigger called "On load complete" which is called when your game finishes loading a previous state -- that's probably what you want, so you can do your increment and save as an action there.

  • One suggestion: after loading your checkpoint save, add 1 to your death count(to bring it back to where it was pre-load), then save again.

  • 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]