dop2000's Forum Posts

  • First, if you are using "Check item exists", you don't need "Get" and "On item get".

    You can access LocalStorage.ItemValue from the "On item exists" event.

    But this should not cause any issues.

    Most problems with local storage happen when people don't wait for Set Item action to finish before reading the same item from local storage.

    For example - at the end of the level 1 you save some item into local storage and then change layout to level 2.

    On start of level 2 you Get the same item from local storage. If you don't wait for Set action to finish before switching to the next layout, then there is a big chance that the item will be read incorrectly.

    Another common mistake is when people don't wait for the Get action to finish before trying to access this data.

    For example:

    Get item "HighScore"

    Score Set text to HighScoreVar

    Use "Local Storage -> On all gets complete" and "Local Storage -> On all sets complete" and "System-Signal", "System-Wait for signal" to properly organize your flow of events.

  • You are misusing "Trigger once" condition, and this is what probably causing those problems..

    Your event 912 makes little sense, because you are checking a system variable, picking enemies instances and looping through them, and have "Trigger once" as the last condition, all in one event. It's impossible to tell how this will work.

    Here is how I would change it:

    Ctrl_Lock=1
    Trigger once
        Enemies Y>10
        Enemies locable=1
        Enemies locked=0
        For each Enemies 
    [/code:8m3olk1i]
    
    Notice that I moved all picking conditions (Y>10, lockable=1, locked=0) before the For each loop. This reduces the number of instances that will be processed by the For each loop.
    
    Also I suggest using sub-events, they make the code better structured and easier to understand.
    
    In event 913 you don't really need the For each loop, you can remove it.
    
    Event 914:
    [code:8m3olk1i]
    Ctrl_Lock=1
        Enemies locked=0
        Enemies strength<25
        For each Enemies 
           lockTarget UIDLink=Enemies.UID -> lockTarget  set frame to 1
    [/code:8m3olk1i]
    
    Event 915:
    [code:8m3olk1i]Enemies locked=1
    Enemies destroyed=1
    For each Enemies 
           lockTarget UIDLink=Enemies.UID -> lockTarget  destroyed
    [/code:8m3olk1i]
  • This is not how this forum works.. Searching for bugs is your job, and if you don't know how fix them, then you post your questions here and someone will help you.

    Also, the link to your project file is broken. Try posting it without the "https://" part.

  • Ok, go ahead..

  • The first event is correct.

    But I'm pretty sure that the second event won't work if you build several building at the same time.

    System-Trigger Once doesn't work per instance, it is a global condition. Once it's true for any building, this event will not be triggered again when you start construction of another building.

    There are many ways you can fix this - you can convert this event to a function and call it once when the building starts. Or you can rename this instance variable to "Building_Progress" and use different values for it: 0-planning, 1-construction started, 2-in construction, 3- construction finished etc.

  • No worries!

  • Try moving the Origin image point in the sprite to the bottom of the image. Then it should grow up.

  • I believe this is the correct formula:

    Building Set height to Self.Height+ ((Self.Total_Height-Self.Height) / (Self.Construction_Timer/0.1))

    Timer behavior definitely allows to perform actions every 0.1s

    So your events with Timer could look something like this:

    Building on created: Start Timer "Grow" for 0.1s

    Building on Timer "Grow":

    ....Building Set height to Self.Height+ ((Self.Total_Height-Self.Height) / (Self.Construction_Timer/0.1))

    ....Building subtract 0.1 from Construction_Timer

    ....If Building.Construction_Timer > 0 : Start Timer "Grow" for 0.1s

  • Not sure I understand your problem with the Construction_Timer variable...

    I strongly recommend using Timer behavior instead of the "System-Every X seconds" event.

    You have much more control over the Timer - each building will be running its own timer, you can have different duration for different buildings, pause timers when the game is paused etc.

    Also, I think your Construction_Timer variable should be instance variable. (different for each building)

  • See this post from Ashley:

    "You can ignore power-of-two image sizes now"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Please share a screenshot of the event sheet where you deal with Local Storage.

  • You are right, you are re-writing the key at 0 instead of inserting...

    I suggest you build the list of keys in an array first. You can insert items into the array (Array->Push action).

    And then clear the list box and populate it from the array values.

    EDIT: ignore that! I was right the first time. "Add item at 0" action inserts new item at the top of the list, all other items in the list move down.

  • I suggest a completely different approach.

    Put an invisible "Sensor" sprite on the floor under the Enemy.

    When player collides with the Sensor (and the enemy is not currently moving), the enemy starts falling.

    Instead of the Bullet behavior use MoveTo.

    First move the Enemy to Sensor sprite. Then, after it arrives (in "Hit the Target Position" event), move the Enemy back to its original position.

  • I'm guessing the expression should be the same and index=0