dop2000's Forum Posts

  • It's not a bug

    Mouse events don't work with Button object, as most Keyboard events don't work with TextBox object.

    Instead of "Mouse->On object clicked" use "Button-> On clicked".

  • If the ball is rolling up the hill it can go a certain distance up the hill. If the ball is jumping while going up the hill it can go further than if it was just rolling.)

    I see this on the video, thanks. But I don't understand your problem.

    Do you want the ball to go further when it's jumping? (as it does now)

    Or do you want it to move the same distance, no matter if it's jumping or rolling?

    Or should the distance be actually shorter when the ball is jumping?

  • Your code in the first comment was more correct (or less wrong).

    "On created" is a triggered event, it's triggered only once. So you should not nest repeating events like "Every X seconds" under "On created", this will never work.

    The best solution would be to add Timer behavior to your SmallDestroyer.

    Also, instead of "Create" action you can define an image point where you want to shoot bullets from and use "Spawn":

    SmallDestroyer on created -> SmallDestroyer start Timer "Shoot" for random(0.2, 0.4) (Once)
    
    SmallDestroyer on Timer "Shoot" -> SmallDestroyer spawn BlueProjectile from Imagepoint "shootPoint"
                                    -> SmallDestroyer start Timer "Shoot" for random(0.2, 0.4) (Once)
    [/code:1tya4kf8]
    
    That's it. Each Destroyer will be running its own Timer, and the Timer will be restarted for a random time after each shot.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Physics objects behave like real-life objects. If a real-life ball is rolling forward and you apply impulse (hit it from below), the ball will jump up and forward, because it has forward momentum.

    So if you don't want it to move forward when jumping, I think you need to remove its horizontal velocity, set it to 0.

    It's only a guess, since I don't have your capx to test.

  • It works for me. Goes to main menu layout, not freezes.

    However, I suggest you make these changes:

    1. Replace "Is touching Home" with "On tap gesture on Home".

    "Is touching" is a continuous condition, it triggers ~60 times per second, which is not good for buttons.

    2. Since you are resetting global variables, no need to set individual variables to 0, you can remove all such actions (set OrangeMark=0 etc.)

    3. No need for "Restart layout", since you are changing layout.

    So basically your event should look like this:

    On tap Home

    Home is visible

    ...............Reset global variables

    ...............Go to MainMenu

  • I asked for your capx because all these destroy actions work fine for me (obviously). So there may be something wrong with your capx or C2 installation. If you share the capx that doesn't work, I can test if it works on my pc.

    Could you include all issues - with text and buttons not getting destroyed, variables not changing etc.

  • This doesn't make sense. Could you post your capx file?

  • rbailey83

    Is your layout height the same as window height? If not, you need to change it in the formula to something like WindowHeight or ViewportBottom(0)

    Also, check the Origin image point on MenuBG sprite, it should be at y=0.

    If this doesn't help, please share or PM me your capx.

  • No worries!

  • "Set velocity" should work, but you need to regulate the speed and apply it every tick, otherwise movement can be slowed down by friction, damping etc.

    I'm guessing when your character moves up a hill, it has some Y velocity, so when you apply an impulse, it adds to Y velocity, making the jump too high. You can try setting Y velocity to zero before the jump, or decreasing impulse strength if character has Y velocity.

  • Use "Physics -> Set velocity", it works instantly.

    For example to move left at speed 100, use "Set velocity x=-100, y=0"

    To move at angle: "Set velocity x=100*cos(angle), y=100*sin(angle)"

    You'll have to modify these formulas if you want acceleration/deceleration.

    Making platform game with physics may be tricky. Have you considered using Platform behavior?

    Platform with Physics don't work well together, but you can disable Platform and enable Physics when you need to interact with other physics objects.

    Or you can make two sprites - one main sprite with Platform behavior and an invisible clone sprite with Physics behavior, that will follow the main sprite.

  • You can use something like this:

    Set platform speed to abs(Touch.Gamma)*10

    Or with clamp to limit minimum and maximum speed:

    Set platform speed to clamp(abs(Touch.Gamma)*10, 100, 1000)

    The more the phone is tilted, the higher the speed will be.

    You can use a similar formula for acceleration.

    Of course you'll have to experiment a lot to get these numbers right.

  • It would be much easier if you shared a capx..

    Ok, first, event #4 should not be nested under "On start of layout". But even if you move it, it will still change state for all NPC at the same moment.

    If you want NPCs to move "chaotically" each at different time, the best way to do this is to add Timer behavior to NPC, start it for random(1,3) seconds, then On Timer event change NPC_state variable and restart the timer again for random(1,3) seconds.

    Initial "Start Timer" can be under "On start of layout" event.

    "On Timer" should be a top level event, like #1, #2 and #3.

    Event #6 is executed every tick, you should not use "Wait" inside such events, this can cause all kinds of troubles. Change your event #7 to this:

    eNPC_state=0 -> Set platform speed=0

    Else -> Set platform to maximum speed

    In event #14 as you are using "toggle boolean", when your NPC see player, they are constantly switching between being casual and annoyed about 60 times per second, because it's also triggered on every tick.

    So you need to add another condition "obj_actor_enpcmask is NOT annoyed" to event #14.

    Also, you can remove "casual" variable. NPC is either casual or annoyed, it can't be both, right? So you only need one boolean variable - annoyed.

    And finally, you don't really need "For each NPC" in any of those events, but it's ok that you have it. I believe it's a good habit to use "For each" condition, it makes the code more logical and can prevent some potential problems.

    I might have missed something, next time please share your project capx.

  • Pipes in this game only exist for about a second, then get destroyed. So we are talking about creating new pipes, no need to change movement for existing pipes.

    Code example that I gave changes Sine movement to vertical for all newly created pipes after 5 seconds of playing.

    You can modify it like this:

    variable MovementType=0
    
    Every 15 seconds
        Add 1 to MovementType
        MovementType=4 -> Set MovementType=0   //  this will reset back to 0 after 60 seconds
    
    Every 1 second ->    Create object bottomPipe
       // no need to add "MovementType=0 -> set movement to horizontal", because that's the default movement
        MovementType=1 -> bottomPipe Set Sine movement to Vertical
        MovementType=2 -> bottomPipe Set Sine movement to Angle
        MovementType=3 -> bottomPipe Set Sine movement to Size
    [/code:d6jam51w]
     
    This will do what you want - first 15 seconds pipes will have horizontal movement, next 15 seconds vertical, next 15 seconds angle, then size, then back to horizontal.
    
    Another way to do this is to add 4 Sine behaviors to the sprite, one for each movement type (rename them to SineHoriz, SineVert, SineAngle, SineSize). Then by enable/disabling them with events you can create combinations of movements, say horizontal+angle, vertical+size etc.
    
    One more thing - it's better to use Timer behavior instead of "Every X second".  With Timer you have better control, you can stop it, restart, check remaining time etc.
  • Does your spritefont (image) actually contain capital letters?

    It works for me:

    https://www.dropbox.com/s/fvc47qc5chedo ... .capx?dl=0