AllanR's Forum Posts

  • Event sheets continuosly loop, executing the code over and over again. So your code to create characters is repeating forever.

    If you want code to only run once when your layout starts (like creating characters), then create an "On Start of Layout" section and then make your "For Each" loop a sub-event of that. Then it will only run when the game first starts.

    Your characters are being set up the way you want, but the info displayed on the screen is the same for each character because all your text fields have the same names - so each time it creates a new character it updates ALL the text fields on the screen.

    To fix that you either need to give them unique names, or select the ones closest to the Spr_Adv_Border, or create the text boxes when you create the Spr_Adv1 charater...

    I tweaked your capx to make it work. you can get it at: rieperts.com/games/forum/DPM-A1-fix.capx

    The reason I suggested a sprite for variables and one for graphics is because the graphics will change based on how you generate your characters (male/femail, old/young, etc.) and as you will give them different animations. You need to have base objects that you know the names of to manipulate within your game. Then you apply the desired graphics you need on top of those...

  • check that you didn't accidentally disable the scroll to behavior, or also give it to something else...

  • Isn't that basically what I said?

    "all we really need is an option to make all layouts share the same layers" is what I meant by having an "Include Layout" in the Layout Properties section, with an option to set the included layout on top or underneath the current layout.

    I do realize that is not quite what the OP was asking for, but I thought "Include Layout" would be easier to implement (and less confusing for people).

  • I think that is a great idea!

    In Layout properties you can choose your event sheet. And then on event sheets you can include other event sheets. It would be awesome to be able to include other layouts (either on top or below the current layout).

    That way if you want a HUD layout, you just include it (at top), but if you have help screens or a shop where you don't want it, you just don't include it on those layouts. That would be easy to implement!

  • bscarl88

    Yes, I still had the capx file...

    you can get it at: rieperts.com/games/forum/BugCheckFile.capx

  • Your project is probably too small, so it loads instantaneously.

    Try adding a really big picture or music file to make it take longer to load...

  • My son has been making games with enemies, and wanted a health bar over each one. So, when he places each enemy on the layout, he puts a health bar near it. Then at the start of the layout he loops through each enemy, picks the nearest health bar, and pins it to the enemy. And puts the health bar UID in an instance variable in the enemy, so when the enemy takes damage he knows which health bar to reduce.

    That is another way to handle this type of problem...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Picking by Unique ID is the way I would do it in this case.

    I Added an instance variable to Particles called Victim, and when the Particles object is created I store the Sprite.UID in the Victim variable so we now know the Sprite that the Particle object is associated with.

    Then I added a loop in the Every Tick section, for each Particles, we pick the Sprite with UID = Particles.Victim, then set the Particles position to that Sprite's position.

    I also randomly create new Sprite objects to shoot... :)

    Oh, I also added Fade to Sprite and Particles, so that they fade out of existence - because the bodies were really starting to pile up, and the Particle instances were still active even after the rate was reduced to nothing.

    you can get the file here: rieperts.com/games/forum/sniper.capx

  • in the Start of Layout section, right now you have

    TimeBar set InitialWidth to TimeBar.Width

    what that does is tell C2 to remember the current width.

    You want to tell it to reset the width to full and reset the time to max.

    so, you want:

    TimeBar set InitialWidth to 352   (or whatever you want for full)

    TimeBar set Time to TimeBar.MaxTime

    Then, when the layout restarts it goes back to a full time bar.

  • TokenAt() is a good way to do that. Then C2 manual say:

    tokenat(src, index, separator)

    Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

    tokencount(src, separator)

    Count how many tokens occur in src using separator. For example, tokencount("apples|oranges|bananas", "|") returns 3.

    So, rather than "(av:james) Hi my name is james" you might just want to have "james|Hi my name is james"

    then tokenat("james|Hi my name is james",0,"|") will return the avatar, and tokenat("james|Hi my name is james",1,"|") will return the text for him to say.

    You can chain together strings, using different tokens if you want.

    "james|Hi my name is james#susan|Hello there!#ben|Good day, eh?"

    just be sure to use tokens that wont appear in your text, or if you are going to pass the strings to php (to save in a database) don't use a symbol that may cause trouble there (like "&")

  • TiAm's suggestion is good.

    Another way would be to have the Scroll To behavior for ObjectA enabled, and disabled for ObjectC.

    When the collision happens, disable it for ObjectA and enable it for ObjectC.

  • The distance() function wont distinguish between different x and y target values, so don't check that way.

    instead, directly compare the x values and the y values. Since the enemies can be on either side and above or below, you could end up with either positive or negative values. so, use the ABS() function (which returns the absolute value, always positive).

    So, where you have the first sub event where you check Distance, replace that with:

    System: Compare two values: ABS(BoxWalker.X - BoxPsi.X) <= 200

    then add another condition:

    System: Compare two values: ABS(BoxWalker.Y - BoxPsi.Y) <= 50

    and, as TiAm said, then later use ELSE where you have the second Distance() function.

  • TiAm is correct.

    so, the way to fix it is to have a main event:

    Keyboard on V pressed

    then a sub event:

    System zoom = 0 - set layout scale to 2 and set zoom = 1 (the way you have it above)

    then another sub event that says:

    ELSE - set layout scale to 1 and set zoom = 0

    (the else section wont run if the first sub event is true, when zoom=0, even though the value of zoom gets set to 1)

  • well, it is impossible to tell without seeing your actual code... it could be just about anything.

    you may have placed the code somewhere that never actually runs.

    Random(15) will return a floating point number between 0 and 14.9999, so the chances of getting an integer are almost zero. If the rest of your code is expecting an integer then use something like Round(Random(15))

    or Int(Random(15))+1 if you don't want it to ever pick zero.

  • Well, I just played around with your capx too.

    The problem is that you are converting the coordinates of the Coin being collected to the actual canvas coordinates, but then you are not converting the canvas coordinates to the HUD layer's coordinates. So, when the game screen does not fully fill the monitor it is off.

    I created two local variables for that section: canvasX and canvasY

    and set them too:

    canvasX = LayerToCanvasX("Main",Coin.X,Coin.Y)

    canvasY = LayerToCanvasY("Main",Coin.X,Coin.Y)

    then created the Coins object at:

    Create object Coins on layer "HUD" at ( CanvasToLayerX("HUD",CanvasX,CanvasY), CanvasToLayerY("HUD",CanvasX,CanvasY) )

    That seemed to work fine. (I slowed the speed of the Coins way down because they were moving almost too fast to see!)

    I still think simple is better. Your capx sure has a lot of global variables and a lot of code. I would try to simplify it by using more instance variables, arrays, functions, etc...

    But, the game looks good! You are well on your way to making some great games! :)

    I can't really tell why the FPS would decrease. It does seem to work fine in the version you uploaded. Like zenox98 said, try using the debugger to see what is hogging all the processing time - you probably have more objects than you think, or something isn't getting reset...