AllanR's Forum Posts

  • WRS

    I was only showing how to store the number of stars in an array, and save that in local storage.

    in your screenshot you store the level name as an instance variable, and that is perfectly fine - I just didn't want to make a lot of levels...

  • WRS

    you can save the entire array AsJSON...

    I made a quick sample...

    https://www.rieperts.com/games/forum/levelstars.capx

  • to pick the object in the second function you would have to pass the UIDs of the TimeText and Clock as parameters:

    function1
    	create TimeText
    	create Clock
    	call function2 TimeText.UID, Clock.UID
    
    
    function2
    	Pick TimeText by UID - function.parameter(0)
    		Pick Clock by UID - function.parameter(1) - then do what you need to do...
    

    as for adjusting the timetext x and y coordinates, you are only looking at the x value for TimeText - which is where it starts. You need to factor in how wide it is to make it fit on the screen...

    I made a sample to show you how I would do it. I did it all in one function because I didn't see any reason to do it in two... but I added a call to a second function just to show how to pass the UIDs.

    https://www.rieperts.com/games/forum/timetext.capx

  • kiugetski

    that is probably the edge of your layout for that layer - because of the parallax settings. put an object on the edge of that layer to see if it shows up, or use layertocanvas from the player's layer then canvastolayer for the background to see what the coordinates are there.

    you may have to create stars farther out than you think because of the parallax... or it could be something else. it would help if you made a sample capx with just the layers, stars and player to look at.

  • heyguy

    C2 will tell you when an animation is finished...

    in your function you start cutscene animation "Scene01"

    so, outside the function make an event:

    cutscene - On animation "Scene01" finished - (then add all the actions after the wait...)

  • s707927

    well, you got me curious... so I looked into it. there is an open source project called StepMania that has hundreds (thousands?) of songs with the song data in various skill levels.

    so, I loaded a song and the dance data, figured out how to parse it, calculated the speed the arrows have to move, and tried to get the tolerance right for hitting the targets.

    this is only about half done - it doesn't keep score, count the hit statistics, combos, etc... and it doesn't calculate the note values properly - it assumes they are all quarter notes. You are supposed to read up to the next comma in the array data and then figure out the note values but that was too much for one night. Because of that, this sample will ONLY work properly with Beginner or Easy skill level.

    the songs also have data for two player mode, and lots of other game features...

    this will get you started, but there is a LOT more involved! it was fun figuring out this much - Good Luck!

    https://www.rieperts.com/games/forum/dancedance.capx

    oh, I have it using the arrow keys on the keyboard, but you will probably want to change that. Also, if you press a wrong arrow key it will kill the next note for that target - even if it should be ignored for being too far away... and lots of other issues too...

  • Gadgetkk

    that could be a browser issue... trying to cascade the windows or something.

    if you maximize the preview window, it should always look the same.

  • Rory

    that was my first comment too... I like to keep my code all collapsed down to the minimum - so it acts like an index. Then I expand just the sections I am actively working on.

  • the "Wait 0 seconds" does not take the picking with it. Functions always reset all picking, and functions are considered part of the event that calls them - whether they are below or above. The eventsheet is executed top to bottom, but functions do not count - their code essentially gets inserted where it is called from.

    so, when you call a function, you can pass in the UIDs of objects to manually pick as a parameter, otherwise whatever the function does will apply to all instances. Do you only have one instance of the clock and timetext?

    For keeping the timetext fully on screen, you will need to know the total width and height required and then adjust the touch coordinates as necessary...

  • kiugetski

    when you create the stars, you can use "Move to bottom" to send them to the bottom of the layer.

    or have a separate layer above all the background stuff for the player and other foreground objects.

  • the problem is that you create the clock and timetext in the first function, and then call a second function. C2 has not finished creating the objects, so you can't access them in the second function unless you pick them by their UID, or wait until they have been fully created.

    they are fully created after the next top level event from where they were created. calling a second function is just extending the original event, but breaks all the picking.

    to make your code work, add a "Wait 0 seconds" action before you call SetTimeText. That tells C2 to not execute actions after the wait until the end of the current tick. By then the objects will be created and your SetTimeText function will work the way you expect.

    You can avoid all the viewport trouble by just saving the touch coordinates from the HUD layer instead of the layout coordinates (which is what happens if you don't specify a layer - as in your code):

    LastTouchX = Touch.X("HUD")

    LastTouchY = Touch.Y("HUD")

    then when you create the objects on the HUD layer they will be at the touch point (and on screen) every time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Toddler

    you can do all that in C2 without a custom plugin...

    I added a MoveThreshold which can help filter out small movements that you might want to ignore.

    https://www.rieperts.com/games/forum/mousemove.capx

  • dop2000

    awesome stuff! I have a whole library of ROJOhound routines! and just added that one...

    although the line followers don't turn like a vehicle. In that last sample I was also trying to leave the door open to additional AI features - like conditional branching at a way point, or stopping. And possibly obstacle avoidance (if the truck in front of you gets blown up).

  • Sangeeth777

    To make it turn like a vehicle required a completely different approach because it was too hard to place the directioner/trigger objects. Knowing the angle to the next point didn't work because a vehicle requires space to turn around - and the amount of space varies depending on the approaching angle and where the next point is in relation to the current point.

    I tried path finding (like dop suggested) but couldn't get that looking accurate either - when it rotated it didn't look like a truck turning (looked like a tank).

    so I changed the trigger objects to know which trigger is the next one to head to, and then the patrol truck keeps turning towards the next point until it is lined up with it (using a pointer object to tell it how far off the angle is and limiting how much it can turn each tick).

    this method works really well and looks like a vehicle to me. I wasn't sure what you meant by changing the animation when the angle changes - do you mean some kind of 3d or 2.5d effect? And I also didn't understand what you meant by reverse and change path. do you mean coming to a stop, backing up and turning down a different road? That is a much more complicated AI, and you would have to define the rules of your world to know what would make the vehicle stop and choose a new route. My method is still using bullet behavior - and bullets don't go backwards...

    https://www.rieperts.com/games/forum/patrolvehicle.capx

  • Sangeeth777

    it looks like C3 handles angles differently than C2 does. If the directioner angle is less than the truck_convoy_base angle, the result is a negative angle. (In C2 the result wraps around and stays in the 0 to 360 range)

    so, you need to change event 9 to make sure the comparison always stays positive. To do that add 360 and then use MOD (%) 360 to keep angle in the correct range.

    (directioner.Angle-truck_convoy_base.Angle+360)%360

    I updated my sample (for people who download it in the future), so that it works for both C2 and C3.

    https://www.rieperts.com/games/forum/patrol.capx