oosyrag's Forum Posts

  • The array has a "Load" action, which you put the JSON string into.

  • Ok I have no idea what is going on with all the layouts and event sheets but you have no "Get Item" action anywhere. Localstorage.ItemValue is nothing until you get an item, and put it in an event with an "On Item Get" condition.

  • On the second layout, you will need to once again check if key exists, then set your variable in an "On exists" event.

  • I'm going to assume you're relatively new to Construct 2, so first I'll direct you to the manual - https://www.scirra.com/manual/75/how-events-work, and hope you have done the tutorials.

    It's going to be a bit difficult if you're a traditional programmer moving to Construct, as you will find that a lot of things you are trying to do are simpler than you might think. Basically, Construct will take care of a lot of lower level stuff for you behind the scenes (such as everything you mention in the last paragraph).

    Specifically regarding your questions - In your event conditions, if you used "On Mouse clicked RedItemSprite", only the one you clicked on will be "picked", and any actions in that event will only apply to those instances that have been picked by the conditions specified.

    So if you're setting flags, only the instance you click on will be picked and have its flag set. You can use a seperate event that runs every tick to keep the instance with its flag set positioned under your mouse at all times. On release, you can reset the flag.

    Regarding limiting which of your instances can be "picked up" - there are many ways to do this, it is up to you to set the condition under which it can be interacted with. Another instance variable as a flag would do nicely. Another useful technique that comes in handy in a lot of cases is to use an invisible helper sprite. Place this invisible sprite over the ones you want to interact, and in the event that lets you pick up items, add the condition that your mouse has to be over this helper sprite. If not, then that event won't run.

  • You're missing quite a few steps. Read the manual entry, follow the tutorial. Localstorage is asynchronous - that means it doesn't run in the same time as your event sheet.

    [quote:1aql7znz]For example here is a flow to read the value of the key "score":

    Use the action Get item "score"

    A moment later, On item "score" get triggers

    In this trigger, use the ItemValue expression to read the item

  • System: Set HighScore to int(LocalStorage.ItemValue)

    NaN means Not a Number. The int() part is important, as it changes a string into a number.

  • Are you loading the score from localstorage only on start of layout? Make sure you are not doing it every tick.

  • You definitely need the localstorage "Check item exists" action somewhere.

  • It works.

    Loopindex does not work for the Array "For each xyz" condition.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Save your scores to local storage, rather than a global variable (or save to the global variable, and save the global variable to local storage).

    On start of layout, load scores from local storage (if they exist) to global variable.

    https://www.scirra.com/manual/188/local-storage

  • Most of the heavy lifting of parsing/string manipulation can be done in base C2 with the tokenat() expression.

    Where that gets too clunky, the regex() expressions should be able to cover any situation, given you're familiar with regex.

  • You'll need to save some information to local storage, and load/check to see if that value is there on start of layout. https://www.scirra.com/manual/188/local-storage

  • Here is the easy answer - use Rex's moveto plugin: http://c2rexplugins.weebly.com/rex_moveto.html

    Second easiest would be bullet behaviour. You'll need a "start moving" event, where you enable bullet and set the direction and speed, and a "stop moving" event where you disable bullet. The conditions for each of those are up to you. (Invisible sprites are excellent tools for this - you can set the invisible sprite as a "target" when you start and stop when you collide with it)

    There are also many ways to create your own custom movement through events.

  • * You can make the spreadsheet in excel and export it as a comma seperated value (cvs) file. Then you can load that into an array either by doing it yourself with a loop and the tokenat() expression or using a plugin made to parse the file.

    https://www.dropbox.com/s/7897xqrs7g51mzc/ParseCSVExample.capx?dl=0