AllanR's Forum Posts

  • sassix

    there are a couple issues with your file - you never save the OfflineTime variable, except for the first time it is run (when the local storage item is missing - and it is set to 0). And you don't really need to save that in local storage because the SavedTime is doing the same job.

    Also, at the start of layout you check for the local storage items and then set the text fields before the items are finished loading from local storage.

    And when a localstorage item exists, you set its value back to 0 instead of setting your global variables with the value from localstorage.

    when you load items from localstorage, you don't know what order they will get loaded in, so you can't do any calculations until you are sure they have all been loaded. So, I changed it so that it calculates the time away when the SavedTime item is loaded and calculates the GoldEarned, but it doesn't add it to CurrentCurrency because that item may not have loaded yet. I only add it when you click the Quit button - where it sets the SavedTime and saves the new CurrentCurrency.

    when you click the Quit button, it starts saving the localstorage items and then closes the browser. I wasn't sure it C3 would know to wait until the items were saved before closing down - and it seemed like the values didn't get saved once or twice in testing, so I made it wait until the items finished saving before quitting.

    https://www.rieperts.com/games/forum/AwayTimeFix.c3p

  • they stopped adding features to C2 long ago - they have just been doing bug fixes.

    there is no way to import a C3 project into C2. you may be able to recreate the project in C2 by looking at the events in C3 and creating similar ones in C2, but there are lots of features in C3 that don't exist in C2.

  • it does get a little confusing at first...

    I don't think of it in x,y coordinates - I always think of it as row,column

    row is the array width, column is the array height

    here is a very stripped down sample of my array functions for loading, filtering, sorting and displaying array data:

    https://www.rieperts.com/games/forum/SampleDB.c3p

  • certainly would be easier to be able to sort the main array by any column you want, but it isn't too hard to do it the way I do. Plus I can control exactly how it works - I can combine multiple columns for a primary and secondary sort order, control whether it sorts alphabetically or numerically. I have functions to do all the work. I set instance variables on the main array that indicate what column to sort by, numeric or alpha, ascending, descending, etc... I pass the UID of the array into the function because I usually have arrays with data from different tables from a database. Loading the arrays with AJAX calls also loads the field names into the dictionary, so I can change the query and don't have to worry about changing any code since I don't access data by column number, only by field name.

  • I do a lot of database work with C3.

    What I do is make the array a container and add two additional arrays - one called Filter, and one called Index. And I also add a dictionary so I can use field names instead of numbers for the columns.

    The Filter array only has one column. If I want to show a subset of the records in the main array, Filter only contains the row number of the main array for records that meet my criteria.

    Then to sort the array, I use the Index array. It has two columns - the first column contains the field (column from the main array) I want to sort by, the second column contains the row number from the main array.

    To build the index, I loop through the Filter array so only records that match the current filter are included. For each row I copy the field I want to index by to the index array (and its row number). Sort the index array by the x-axis (and reverse if I want it in descending order).

    I have used this with arrays that have thousands of records, and it works great - even on mobile! I can filter and sort a very large array instantly.

  • I would do something like this:

    I added the Pick top instance just in case you have overlapping instances, because a mouse click over multiple objects will trigger the clicked event for each object the mouse is over.

  • under System Loops you will find "For Each"

    select the object type and it will loop through each one, each time through the loop only one of the objects will be selected, or "Picked". then as an action for the loop you can set the properties of the current object, and you can use the "LoopIndex" keyword to multiply x by (it will be 0 for the first instance of the object and will increase by one each time through the loop).

  • hard to say without seeing what you have in mind...

    how many menu items are there? aligned vertically or horizontally? evenly spaced out over the menu, or top or left justified? Are the menu items sprites? text objects?

    do the menu items need to be pinned to the menu so it can slide on or off the screen?

    how are the menu items sorted? is there a sequence they need to be in?

    It would help if you could post a sample project with a general idea of what you want.

    it doesn't make much of a difference if the items are created at runtime or not.

  • Tab order is set by z order - the lowest in the z-order will get the focus first, then up to the highest.

    (and Ashley is male)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • it doesn't like the fact that the address is http, not https

    you may be able to click the little cloud in the top right corner to allow it to read insecure data, but I am not sure if that will work.

  • there are a few ways to do it, you can set angle of motion to "angle(start.x, start.y, player.x, player.y)"

    or you can set the bullet object's angle using "Set angle towards position" and give it player.x and player.y

  • If you add the Browser Object you can run javascript to return the current time on the device (computer/phone/tablet)

    Browser.ExecJS("const CurDate = new Date(); CurDate.getHours();")

    the above will return the current hour - from 0 to 23.

    if you want to prevent people from changing the time on their device to cheat, then you have to request the current time from a time server using AJAX, but if someone wants to cheat, they can get around that too.

  • if anyone stumbles across this in the future, I ended up filing a bug report:

    https://github.com/Scirra/Construct-3-bugs/issues/4255

    Because of worker mode, there is no easy way for this to be fixed. The solution Ashley suggested was to dispatch the input event after updating the value in javascript.

    const elem = document.getElementById('input1');
    elem.value='test 1 2 3';
    elem.dispatchEvent(new Event("input"));

    This works great, and has the added benefit of causing the "On Text Changed" trigger to fire.

  • That is correct...

    I just checked my sample with debug mode, and saw that the angle gets set to 0 when the speed is set to zero.

    I thought that might be a bug, but then I read up on the Bullet behaviour in the documentation, and it says that is how it is supposed to work. So, your solution of storing the angle is the best option.

  • if the bullets change direction, then you have a picking issue somewhere in your code. When you think you are setting a new bullet's angle, you are accidentally setting all of them.