aerirprown's Recent Forum Activity

  • RenatoB

    You could do something like this.

    For each object

    is object on screen

         use the array push action to add the object's UID

    Select a random value with round(random(array.length))

    Pick object by UID

        

    To pick more than one, use the pop action to remove the one already selected and then select another random value from the array.

  • RenatoB

    The count expression is accessed by sprite.count

  • You could make a variable to track which turret is currently selected by assigning it either the turret's UID or IID.

    Then on your events when upgrade is touched, find the turret with the matching UID or IID and then perform the actions.

    Right now you are not picking a specific redturret for example, so it applies to all of them. I did the redturret as an example.

    dl.dropboxusercontent.com/u/119307545/simpledefense.capx

  • sgn15 You could use a boolean variable "ready" that you check whenever there is input. If it is true then you proceed with the input.

    Then you could set it to false when the character is performing a complex action that should not be interrupted.

  • I got it working using Ashley's suggested method.

    I offer 2 save slots in my game. On main menu, there are 4 buttons. 2 to clear each of the save slots. And 1 button for each save slot. Each save slot button has 2 frames. "New Game" and "Continue".

    On the start of the main menu layout, I check web storage to see if the key "save1" and "save2" exist. If it does, the corresponding slot button is changed to "Continue". I have 2 variables, save1Exists and save2Exists. If the web storage key exists the corresponding variable is set to 1.

    When either of the save slot buttons are clicked, the system checks if the corresponding saveExists variable is set to 1. If it is, I have another variable called "savedGame" that is set to the value of the web storage key of "save1" or "save2" depending on which button was clicked. Then I load the game from save slot savedGame. The game is only saved at the main layout.

    If the saveExists variable is not set to 1, I set the web storage key "save1" or "save2" to "myGameName(1 or 2 depending on save slot)". I then set the savedGame variable to this web storage value. Then I load the main layout.

    When the main layout loads, the game is saved to save slot savedGame. This main layout is more of a hub layout for the player to move between doing missions, purchasing upgrades and such.

    There may be a better way to do this but, this worked for me.

  • Thanks for the replies. I will give it a try and report back.

  • Has anyone used the full state save/load feature successfully?

    I can't seem to figure out two things.

    1. Check whether a saved game exists. I read that you can use web storage to check, but it does not appear to work.

    2. Clear saved games.

    Do you just have to use web storage instead of the full state load/save?

  • I would do it something like this.

    Function placeTurret

    Set prototypeX to random(layout.width)

    Set prototypeY to random(layout.height)

    If distance(prototypeX, prototypeY, player.x, player.y) <= turret.range

    ------->call placeturret

    else if prototype variables are outside layout

    ------->call placeTurret

    else set turret x/y to prototypeX/Y

    This way the function calls itself until an acceptable value is found. You would initiate it by calling this function upon creating the turret.

  • I had a large animation(large in pixels not frames) that made my game stutter for a second when it was created. So I just spawned it on the start of the layout and toggled between visible/invisible and placed it in the correct place.

    That way you could avoid constantly creating and destroying the animation.

  • The way I would do it.

    Spawn the object off screen. The object would have variables prototypeX and prototypeY. You would perform your placement calculations on those variables and check if they would be acceptable(on screen and out of range of the target).

    If the prototype variables are acceptable then set turret.x and turret.y to the prototype variables. If not redo the placement calculations on the prototype variables until you have acceptable values.

    You might have a system to note why the values were unacceptable and seed the recalculation accordingly.

    You could bypass the prototype variables and just move the turret around until placement is correct, but on the off chance the game slowed down during that moment, the moving turret might be seen.

  • I am fairly certain that all a sprite's animations are loaded when it is created. If you have multiple instances of the same sprite, though, it does not load the animations for it multiple times since the animations are already loaded from the very first instance.

    I've seen many people recommend using one sprite for objects that behave the same. So I think you are following good procedure.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have seen it mentioned that any graphics we import, should already be the correct size before import. I had already decided to remake most of the graphics for my game so I made sure they were the correct size before importing. I also did not crop them within the C2 image editor.

    I notice that even if I resize images within C2, the image files exported for my C2 project appear to be the size that I resized them in the image editor. Can anyone confirm whether resizing images in the C2 editor affects performance. I do not mean resizing during the game.

    Another performance question I had. Does having collision enabled on objects that will never use collision, and are never checked for collisions affect performance? I am just wondering because I did not know if C2 did a behind the scenes check.

aerirprown's avatar

aerirprown

Member since 26 Dec, 2012

None one is following aerirprown yet!

Connect with aerirprown

Trophy Case

  • 11-Year Club
  • Email Verified

Progress

12/44
How to earn trophies