linkman2004's Forum Posts

  • Try using the browser object's "Is online" condition instead -- "On went online/offline" are triggers that won't run unless the state of the connection changes.

  • Store the current version number in local storage, check against a constant holding the current version number at game launch. If they're different, clear local storage and store the new version number. This ensures clearing the local storage after booting the new version for the first time. A quick example. Change the CURRENTVERSION to test.

  • The drag and drop behavior allows you to limit the axis upon which an object is dragged to strictly vertical -- this is found in the behavior properties. To limit the Y range, every tick you can set the Y position of your Sprite to something like the following:

    clamp(Sprite.Y, LOWBOUND, HIGHBOUND)

    LOWBOUND and HIGHBOUND being whatever you want to limit your min and max Y values to respectively.

  • The math way:

    Create bullet at: Sprite.X + cos(angle(Sprite.X, Sprite.Y, Mouse.X, Mouse.Y)) * 100, Sprite.Y + sin(angle(Sprite.X, Sprite.Y, Mouse.X, Mouse.Y)) * 100

    You can also store the calculated angle in a local variable so you only have to calculate it once, then substitute that variable into the equations.

  • If you want the position of your sprites to constantly snap to a grid as you drag them, then you can set the position of the sprites every tick to something like this:

    X: round(Sprite.X / TileWidth) * TileWidth

    Y: round(Sprite.Y / TileHeight) * TileHeight

    TileWidth and TileHeight being whatever size you want your grid squares to be.

    Alternatively, if you want smooth dragging, but for the final positions to be snapped to a grid, you can set the sprite's position to the above formula upon the object being dropped.

  • Do you have "Active at start" in your Fade behavior properties set to "No"? If not, it will start fading upon starting the game.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've prepared a quick example to show how this can be done. I'm not sure how you have your object moving, so I set this one up to move at 100 pixels per second along the X-axis and to use the sine behavior on the Y-axis, but the same concepts should apply regardless.

    Sine Facing example

    There's a small bit of calculus involved to get what we want. We start off with our position functions for the object, which are as follows(not Construct 2 expressions, but close):

    X: InitialX + 100t

    Y: InitialY + Magnitude * sin(CycleAngle)

    Take the first derivative to find the velocity:

    Vx: 100

    Vy: Magnitude * cos(CycleAngle)

    Now that we have the velocity, we can use the angle() expression that I outlined in my original post to find the direction of travel. Note that with the sine behavior, Sine.CyclePosition is just the normalized angle used when calculating the oscillation, so we multiply 360 to turn it back into degrees.

    As an additional note, please try to avoid so many posts in a row in the future -- you can always edit new information into your previous post.

  • I'll assume since you're talking about acceleration you mean 1 px/sec^2. If you have direct control over the speed, set it to something along the following lines:

    speed = speed + dt   equivalent to    speed = speed + 1 * dt[/code:b9cuhztl]
    If you're unaware of dt -- short for delta time -- I'd suggest looking at [url=https://www.scirra.com/tutorials/67/delta-time-and-framerate-independence]this useful tutorial[/url].
  • If you have access to the X and Y motion vectors for your object, the angle of motion can be obtained from the expression angle(0, 0, VectorX, VectorY). However, I may be misunderstanding exactly what you're looking for -- a capx or a diagram would be useful.

  • It's generally wise to have an event sheet with the bulk of your game logic which you then include in the event sheets for your individual layouts. See the manual entry on Event Sheet Includes.

  • purplemonkey, I took a look and I know what the problem is. If I have time this weekend, I'll see if I can get a fix out.

  • The method you mention in your second post is likely how anyone would advise you to go about it(if everything is on one layout). If done right, it should prove to be a relatively clean solution.

  • davidross900 - No duplicate threads. I've merged your two threads asking the same question.

  • See my response to this eerily similar question from yesterday.

  • Either stop incrementing spawn time when it reaches a certain value, or clamp your random() expressions in events 1 and 2, as follows:

    (1) every x seconds | clamp(random(5-SpawnTime, 8-SpawnTime), 1, 8) | Create Object | enemy1
    
    (2) every x seconds | clamp(random(1-SpawnTime, 3-SpawnTime), 1, 3) | Create Object | enemy2[/code:3b12fxkd]
    See the clamp expression on the [url=https://www.scirra.com/manual/126/system-expressions]System expressions manual page[/url].