AllanR's Forum Posts

  • well, there would be a variety of ways it could cause a performance hit: in addition to memory, they could reduce your FPS if they are being moved around, or have behaviors that eat up CPU time, or are triggering collision checks.

    Why would you need a lot of empty sprites? to hold data? You could store data other ways.

    I know there are plenty of good reasons to use invisible sprites (I use them to track touch points in a multi-touch interface, or make larger targets around small objects that are otherwise difficult to touch on a small screen), but just make sure you use as few as necessary and keep them as simple as possible (no behaviors, disable collisions, etc.)

  • well, there could be many possible ways to do it... you could have an animation play on collision with the floor (so the compression effect would be done through the artwork). If your object is complex, you could use Spriter to build an animation where the parts squish together. If your object is simple, like a ball, then you could just adjust the height of the object to make it looked compressed for a short while, then set it back to normal...

  • DetteMan

    easiest way is to create an event for your object (blocks or whatever), use "Is playing animation" (and give it the name of the animation you want),

    then add an action to set a variable or display in a text box: objectname.PickedCount

  • Yeah, either you have to assume what the max is (100), or you need to store what the max is.

    You could have a table (array) that holds the max for each type of unit / enemy rather than store the max in each instance, but then you have to store the unit type in each instance so you can look it up in the table - so you aren't really saving anything, unless there is other data you want to define for each type as well - size, weight, weapons, abilities, vulnerabilities, etc. Then it would save on variables if you store just the type, and then look up all those other attributes (including MaxHP) based on the type, rather than having every unit duplicate all info that is the same.

  • put all enemies in a family and make those variables instance variables of the family, then everyone will inherit the default MaxHP. You can override individual enemies if you want to make them stronger or weaker.

    But you do need both variables to calculate what percentage dead or alive they are.

  • well, you could add another Boolean flag for the exempt ones, then only delete the ones that aren't pinned and not exempt.

    Edit: actually, you could probably do it with one flag - just the exempt flag. When you pin an object, just make it one of the exempt ones.

    Then after recreating objects, only exempt ones would be duplicates. I guess you would have to check for the exempt flag in an On Created event, and delete them there.

  • if you select by the Boolean variable, and another condition "not is pinned"

    then you would only delete the new duplicates.

    I know how you feel about creating something only to destroy it. But that may be less expensive than any other system of tracking and deciding what to recreate. It is probably only a little pointer you are wasting - don't think of it as some giant image : )

  • If you can easily identify which of the recreated objects should be pinned, but aren't, can you just destroy those?

  • Proxyma

    Here is a similar approach I took to create an angry bird type game. The farther you pull back on the slingshot, the more velocity you give the projectile... it plots a dotted line to show where the bird will go.

    http://www.rieperts.com/games/forum/angry_birds.capx

  • KyleSousDor

    set a global (or local) variable ReturnPoint to > Choose(1,2,3,4)

    then find path to > base.imagepointx(ReturnPoint) base.imagepointy(ReturnPoint)

    that assumes that imagepoint 0 is the origin and not one of the possible return points...

  • BattleJenkins I might see if I can do it without using collisions, but that would mean finding another way to keep track of where bubbles are...

  • OK, I wrote some functions that do the absolute minimum work - no extra looping. The match testing only runs when needed (when a bubble has settled), and the connected testing only runs if bubbles have been destroyed. Both tests set a flag on each bubble so that it knows which ones have been tested and which ones still need to be tested.

    For the match testing, it starts with the bubble that has just settled, and only tests the ones around it that are the same color, and stops when it can't find any more - so there is no wasted testing. Then, if bubbles are destroyed it calls the connected test - which uses a very similar technique starting at the top, and working its way down, all in one pass.

    It runs nice and fast on my iPhone...

    http://www.rieperts.com/games/forum/CBPuzBob.capx

  • The great thing about Construct 2 is that you are only limited by your imagination - there certainly are a number of ways you could do that, but it is hard to make a suggestion when we don't know what you have in mind.

    Do you mean something like a planet rotating on its axis while it orbits around the sun?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The Wait x seconds command does not stop all execution of code. It only affects the lines immediately after it.

    So, the last two lines of the function "onCollision" will happen after the wait, but the rest of your game code will continue to run every tick (1/60 of a second). That means if you call "RestartFunction" right after calling "onCollision" then that will happen in the SAME tick.

    Another thing to be careful of is that after the wait time is up, when those last two lines do execute, the function will no longer have the same objects picked. In your case you may only have one explosion object, so it would probably be ok. But if your function is meant to do something to one enemy, then lines after a wait command would apply to all enemies unless you re-pick the one you want.

    You could move calling the RestartFunction inside the onCollision function (after the Wait line). Or have a Game Over message pop up, and have the user decide when to restart while the explosion is still running in the background...

  • you need to add the layer's name to the touch x and y reference to get the correct coordinates for the scaled layer.

    Touch.X("Layer 0")

    Touch.Y("Layer 0")

    just replace Layer 0 with the name of your layer...

    EDIT: I see Usman Haq beat me to it, however in that thread the suggestion was to use the layer number. Using the layer name is safer because if you add layers later (like another background layer at the bottom), you may break your code because layers will get re-numbered but the name will stay the same.