AnD4D's Forum Posts

  • Ahh, does the same apply for the 'for each'?

  • Hi guys!

    Having a bit of trouble with the repeat and for each tool.

    Basically, I want to be able to create an object a certain number of times. The system will count how many times an object appears, and then create that many additional objects which then are placed atop.

    The problem is, the loop never seems to stop. I even tried "Repeat 10 times - create object", and it just goes on and on.

    Repeat Test

    My For Each is getting similar results.

    Now I've looked at other posts, and found the one on health bars quite interesting, but I don't think it applies to what I'm ultimately trying to create. Eventually I'd like to use the same tool for creating multiple pivot points, but I think it's way above my help at the moment.

    If someone could correct the Repeat program I made, I'd be very grateful. If there's any bright sparks that know how to create a pivot point with physics for each object, then I would be very happy.

    The idea I have is that if the system finds a pivot sprite, it will create a rotating physics bar to it. I tried to do this manually, but all the bars were linked to the same pivot point. Looked odd :)

    Any help would be greatly appreciated!

  • Do you know how to use arrays?

  • Hi, this may have been resolved in 96-100, so apologies if it has been.

    I have an event which is as follows:

    Upon clicking with mouse on button "NextLevel" activate group 1

    Upon touching button "NextLevel" activate group 1

    Group 1 - Every tick, go to level 2

    I put this in place so if I ever needed to change the level, I only had to alter one line.

    Now, on PC, this set up works fine. If you click it, it goes to the next level. If, however, I try it on Cocoon, it never changes level. I was able to resolve just by having:

    Upon clicking with mouse on button "NextLevel" go to level 2

    but it's not exactly how I wanted it to work. Is this a bug? It's just strange it works on pc, but not on a mobile device.

    Maybe this is a Cocoon glitch instead...

  • Ooh, tricky. Could be a fun one to try to pull together. I would start off by converting the bar width into a percentage local variable, and then have an every tick event setting the width to that event.

  • What I would do is have solid sprites in areas where the objects can not spawn, and have a 'spawner' sprite that changes its position randomly. Then have a condition that says that if the spawner sprite is not overlapping the solid sprite, then create object.

  • Fascinating... this method does it with only the use of 1 variable and 1 additional line. I can then have another variable that I can use to store the data. I really like that there's so many ways to do one thing. I like having options.

    Do you happen to know a way to have it display 00:00:000 (note the 3 at the end). This would enable me to have it as more precise.

    Thanks for your help!

    EDIT: Ahh, done it!

    zeropad(floor(timer/60),2) & ":" & zeropad(floor(timer)%60,2) & ":" & zeropad(floor(timer*1000)%1000,3)

  • Probably not the most elegant, but I've fixed with by adding a second event.

    1) right("00"&(int(milliseconds / 60000) % 60),2) & ":" & right("00"&(int(milliseconds / 1000) % 60),2) & ":" & (milliseconds % 1000)

    2) left(CurrentTime.text,9)

    This allows the code to be shown correctly, but I'm sure there's an easier way from within point 1).

    Any ideas?

  • Ahh, that seems to be a lot closer. I'm trying to have it display as 00:00:00, and have tweaked the code enough to show the first two sections correctly, but I'm falling down at the millisecond section which is either showing the full range of numbers, which is daft looking, or the right length but not showing the first 3 digits of the milliseconds:

    right("00"&(int(milliseconds / 60000) % 60),2) & ":" & right("00"&(int(milliseconds / 1000) % 60),2) & ":" & left(right("000"&(milliseconds % 1000),3),3)

  • Hi R0j0hound,

    Thank you for your reply. I'm not able to get that working I'm afraid.

    The code you have given me shows the timer very strangely. When it reaches 61 seconds, the other sections of the timer does not change, and it happily counts up to over 100 without the other seconds being added:

    E.G: 0:0:101.56789

    Do you know what I'm missing? At the moment I have:

    Add dt to timer

    Set t to timer%1000

    Set text to (int(t / 60000) % 60) & ":" & (int(t / 1000) % 60) & ":" & (t % 1000)

    This gives me the strange series of numbers.

  • :( That's one of the problems with beta... I can't open the example files from stable.

    Thanks for your help! I've tried to recreate what you've described, but it doesn't seem to be working, so I've installed r99 on my laptop.

    Never heard of zeropad, but this is giving exactly the same result that I currently have but with 3 milliseconds being shown rather than just 2. Judging from this, if I wanted to store the time as a best time, I would need to save all 3 things like I'm doing now (Mins/Secs/Mills)...

    Say for example I just have a random number of milliseconds. 12345678. Is there a formula which will allow me to convert this into minutes, seconds and milliseconds. This way, I only need to save the milliseconds for each level.

    My level works perfectly now, but it's untidy and I forsee it being hard to manage. It's around 24 events long, but I think I can get it lower than 10 with this other method.

  • Hi R0j0hound,

    Thank you for your reply. I'm not able to get that working I'm afraid. I currently have the code:

    Add dt to Timer

    Set minutes to floor(timer/60)

    Set seconds to floor(timer)%60

    Set milliseconds to timer%1000

    Set TimeScore text to:

    right("00"&minutes,2)&" : "&right("00"&seconds,2)&" : "&left(right("000"&float(milliseconds),3),2)

    I then convert these to milliseconds using:

    CurrentTimeVar = Milliseconds+(seconds/1000)+(Minutes/60000)

    However, this displays the milliseconds as 0.0000 and 1 second shows at 1.0000.

    The code you have given me shows the timer very strangely. When it reaches 61 seconds, the other sections of the timer does not change, and it happily counts up to over 100 without the other seconds being added:

    E.G: 0:0:101.56789

    At the moment it's being used for a best time, so I'm having to store the min, sec, and mil data. It would be a lot better if I just saved the mil and converted it to 00:00:00.

    Kind regards.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have a timer set up which displays minutes:seconds:milliseconds. Each kind is its own variable. It's displaying it as a text box, and so I can not use it to compare best times, etc.

    I have a formula which converts all the variables into milliseconds, but am wondering if there's a way to split them back up into minutes, seconds and milliseconds.

    Or if there's a simple way to provide times and best times. It's turning into a real mind-bender.

  • Managed 33 seconds :) LOL! Scratch that... 54 seconds... Got killed by a missile. Slightly unusual :)

    Physics seems quite floaty. I'd try increasing gravity a little bit. Maybe let the penguin rotate so it's sliding down ramps, etc.

  • Thanks for that! I may have explained incorrectly though. I would say for example I would like 2 different layouts to appear on the same screen. Is that possible? Player 1 and player 2 at different points in a level for example, split screen?