mekonbekon's Recent Forum Activity

  • mekonbekon Thank you man.

    I don't really understand your capx, the pieces location are in their specific anchor just like my, yellow piece are in yellow anchor, red piece in red anchor and so on.

    What I wish is every time i run the game the pieces go to a random anchor, a simple formula for Y would do it, I still trying to figure her out but she is making herself difficult!

    If you rerun the capx each time you'll see that the order of the anchors and pieces do change.

    If you want to keep the anchor order the same, just add a line of anchors to your layout then spawn the pieces in a similar way to how I've outlined on top of the anchors. Add an instance variable to the anchor (e.g. pieceID and do a check for overlapping with a piece: if overlapping set the anchor variable to the piece frame number.

    As I mentioned above, you don't really need the anchors: you can put all the piece frames on a single object, spawn multiple pieces in a random order and then save their initial position values to instance variables, saving you having lots of extra objects in your layout.

    Hope that helps

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here's a way to shuffle the pieces and apply them to anchors - you can move the pieces and see the anchors underneath.

    If you're just using single frames for the pieces then I'd suggest sticking all the images as frames in one animation.

    https://www.dropbox.com/s/odo9p34kstf2r ... .capx?dl=0

    Notice that you don't really need the anchors if you use this method, you can just spawn all the pieces. You can then assign a couple of instance variables to the piece to record each instance's starting X,Y position, then you can use those values if you need to reposition them on the sliding bar.

  • Maybe this would work:

    On function "changedTouched"

    Square is playing animation "small": Action: Square play animation "newanimation"

    Do you have a capx you can share?

  • Hi justifun - I know you've got a solution from 99Instances2Go , but this problem stuck in my brain and I couldn't let it go, so here's one I came up with:

    https://www.dropbox.com/s/viwoutpz4by0g ... .capx?dl=0

    I haven't been able to view 99Instances2Go 's as it's done in a later version of C2 - so apologies if it's the same.

  • PixelByPixel

    Had to fiddle around with the events a bit (the check for loops not equalling zero was broken, but this works:

    https://www.dropbox.com/s/jim9fwrlhqtbf ... .capx?dl=0

  • PixelByPixel

    Hi there, you need to use Pick Overlapping Point, not Pick by Evaluate.

    And also your local variables should only be referencing the starting object, i.e. the object in the middle - you don't need to pick all.

  • sbz For future reference, seeing as you've already found a solution

    The first line would be using the System|Compare two values condition, and you'd fill the fields in as follows:

    First value: distance(player.X,player.Y,object.X,object.Y)

    Comparison: less than

    Second value: 4 (for example)

    Hope that makes more sense.

  • Make sure you're not playing the sound every tick - use a "trigger once", for example.

  • Hi Trimeister No worries

    To make NOT you invert the condition: right click on the condition and select the "invert" option; it should add a big red cross to the condition. This is very useful for lots of conditions, so bear it in mind for the future.

    For the angle you need to use the "angle" expression: select the "within angle" condition and in the angle field write "angle(enemy.X, enemy.Y, object1.X, object1.Y)". This provides you with the angle between two objects.

    If that doesn't work give us a shout.

  • FabianB

    Glad to be of help

  • The wait 2 seconds will trigger every tick as well, so after two seconds it will start trying to turn to object 2, but at the same time it's still trying every tick to turn to object 1 so it will remain facing object 1.

    I'm guessing what you would like it to do is rotate to object 1, wait 2 seconds and then rotate to object 2?

    If so, this should work:

    Add an instance variable to the enemy called "target"; set it to 1.

    Add a timer behaviour to the enemy.

    Add this code to your event sheet:

    Event: enemy| instance variable "target" = 1

    Sub-event: enemy| NOT is within angle 2 of angle(enemy.X, enemy.Y, object1.X, object1.Y): Action: enemy| rotate 2 degrees towards (object1.X,object1.Y)

    Sub-event: enemy| is within angle 2 of angle(enemy.X, enemy.Y, object1.X, object1.Y): Action: enemy | set timer "wait" to 2 seconds

    Action: enemy | set instance variable "target" = 0

    Event: Enemy| On timer "wait": set instance variable "target" = 2

    Event: enemy| instance variable "target" = 2

    Sub-event: enemy| NOT is within angle 2 of angle(enemy.X, enemy.Y, object2.X, object2.Y): Action: enemy| rotate 2 degrees towards (object2.X,object2.Y)

    Hope that helps

  • Do you mean each enemy has it's own health bar, for example over its own head?

    If so, create a sprite called "healthbar" Add the pin behaviour to it. Add an instance variable called initialWidth and set it to the starting width you want for the healthbar.

    Add it to a container with the enemy; when an enemy is created it will automatically create a healthbar object. Give the enemy "health" and "healthMax" instance variables - set both of these to the max health of the enemy.

    Add this code:

    On enemy created: Set healthbar position to (enemyX, enemyY-(enough pixels so that it appears above the enemy's head))

    Pin healthbar to enemy.

    When an enemy takes damage you want to reduce the width of the health bar, e.g.:

    If enemy collides with bullet: enemy|subtract 1 from health

    healthbar set width to healthbar.initialWidth*(enemy.health)/(enemy.healthMax)

    Because the healthbar is in a container with the enemy, only the healthbar for that enemy will be affected.

mekonbekon's avatar

mekonbekon

Early Adopter

Member since 9 May, 2014

Twitter
mekonbekon has 13 followers

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x2
    Popular Game One of your games has over 1,000 players
  • Famous Game One of your games has over 10,000 players
  • Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

19/44
How to earn trophies