TheDoctor's Forum Posts

  • his old moneybag

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Tell us how it goes!

  • TheDoctor

    Thank you for all the feedback. Can you send me the specs on your tablet. Im going to try to make a emulator for it. I did not get that error my nexus 10 tablet.

    I didn't get any errors when running your app. Just saying I have seen that error before on my tablet.

  • Yann, thank you.

    I'll consider this thread closed now and I'm going to look more into Nested Loops to see if C2 really has that functionality...or start a new discussion on it.

  • my attempt...

    wait loopindex*delay

    Thank you, still, unfortunately, not what I was looking for, but very interesting to see how people tackle same problem.

  • Loops works fine inside events, but you have to understand how C2 execute code.

    When C2 reads it start from the top and go through each event and execute whatever it should.

    When it reaches a loop it will repeat the loop X amount of times, before moving on.

    The wait statement is a bit weird and think that might be what confuse you. The wait statement, doesn't store X amount of waits even if you repeat it 90 times. It will do it once when the wait timer is up.

    There are nothing wrong with using loops in conditions as long as you know how C2 handles them. Hope that makes it a bit clearer.

    Well, loops inside events aren't truly executed within an event if it is as you say. I will post another topic on NESTED LOOPS, which may be what I was getting at. Other programming languages handle loops entirely within their nested position in code, without the use of global variables...it seems C2 does not.

    In most programming languages I've worked with, an example like this:

    On Mouse.click

    {

    Repeat(90)

    {

    System.Wait(1)

    Sprite.Rotate(-1)

    }

    }

    here you can see that the loop, Repeat(90), is nested inside an event, Mouse.Click. Here, when the mouse is clicked, it starts the Repeat loop which will: tell the system to wait 1 increment of time, then rotate the sprite counterclockwise 1 degree, then tell the system to wait 1 increment of time, then rotate the sprite counterclockwise 1 degree, then tell the system to wait 1 increment of time, then rotate the sprite counterclockwise 1 degree, then tell the system to wait 1 increment of time, so on and so forth until that was done 90 times and THEN exit the loop. Inside the loop code, Repeat, it executes whatever commands it finds there from top to bottom until it is done and then it exits the loop.

    C2 seems to run a nested loop only once and then exits. Of course, if the loop isn't nested in C2, it seems to work fine. At least, that is how I see it so far.

  • Give the sprite the "rotate" behavior(Disable at initial, set the speed you want)

    and a instance variable(let's call it 'anglePrev')

    Your condition > anglePrev = sprite.angle / Enable rotate

    Sprite.angle=anglePrev+90, Trigger Once > Disable rotate

    I don't see where you disable the rotation behavior.

  • Yeah you can run a loop if conditions are made, but what you are trying to do, is not possible the way you want to do it. Because a loop is not based on the time scale you are aiming for. To make what you are trying to do work, you would need to know how fast the loop is executed, as I understand you. Which would be near impossible to figure out as I see it.

    According to the manual,

    Wait

    Wait a number of seconds before continuing on to the next action or sub-events.

    So, my thinking is that when it reaches my "Wait" it will "Wait a number of seconds before continuing on to the next action or sub-events." This is what it does outside of a condition, but inside not so.

  • Uhm, that works, but it doesn't answer my question...unless you are trying to say "NO, you can not use a loop inside of a condition being met."

    Thanks though for giving me a way to do it, but I am really trying to understand using loops like REPEAT. Like I said, I can get them to work PERFECTLY outside of a condition being met, but once I put it inside a condition being met it does not work.

    Can anyone answer my question?????

  • And remove the wait and move the rotate up, and type 90/60 as how much it should rotate, it will make it rotate 90 degree every 1 sec.

    "Every tick"

    Rotate object 90/60 degree.

    That's wonderful if I want to do something "Every Tick". I don't want to do it every tick, I want to do it only 90 times and USING A LOOP INSIDE OF A CONDITION BEING MET. That is the topic of my entire post. I want to know how to structure it.

    I am basically asking everyone "Can a loop be executed inside of a condition being met?"

    I don't want to use a behavior, I don't want to call a function (tried both of those still couldn't). I simply want to know how to structure a loop that fires off only once a condition is met.

  • It will use the ticks iteration of 60 automatically.

    What you can do is add a Boolean variable to the objects that you need to rotate, called "Rotating"

    In the event that rotate.

    Object.Rotating true

    Object.rotate clockwise = 90 / 60

    And then you set it to false again when its done rotating.

    Oh boy, do you have an example of that? What you say works fine outside of a condition being met, but not inside. I simple want to see one loop that works inside a condition being met.

    For example, see my code picture above? Can you make that work by making a simple change?

  • You have two actions for rotating objects.

    Rotate Clockwise

    Rotate Counter-clockwise

    They are under the Angle section in the action menu.

    And neither one of them has a number of iterations. That code will only move once. Only move a fraction of the full 90 degrees.

  • This works while the condition (Mouse On any Click) is Toggled to Disabled.

    Once I Toggle the condition to Enabled (not crossed through) it only moves 1 time not 90.

    What am I doing wrong here?

  • Since C2 runs 60 ticks every second. You have to divide the amount of degree you want to rotate every second with that. You don't need a loop you can just do it every tick.

    Action:

    Rotate <Something> clockwise = 90 / 60

    Will rotate it 90 degree every 1 second.

    Rotate <Something> clockwise = 180 / 60

    Will rotate it 180 degree every 1 second etc.

    I fail to see how you implement on the event sheet....I do not see a corresponding action for that.

  • I am trying to rotate my player 1 degree counterclockwise 90 times with a fraction of a second inbetween rotations when a condition is met. I want the user to see the player on the screen actually rotate not just jump to 90 degrees.

    I've read the manual about loops, I just can't get it to loop 90 times inside when a condition is met. Outside of a condition, no problem. I can't find a tutorial either.

    This is becoming a real headache.