monitz87's Recent Forum Activity

  • In fact, you could transform those last 3 events into only one, if you keep the names of the animations in an array and then do

    enemy_bbox isCurrentlyAttacking = 0 -> enemy Set animation to AnimationArray.At(int(random(3)) (play from beginning)

    ----------------------------------------------------- -> enemy_bbox set isCurrentlyAttacking = 1

  • :deleted last post, I think I got it working: Does this look right? Thank you very much!

    [attachment=0:zggap7g7][/attachment:zggap7g7]

    The last 3 events should be subevents of the first one, because if not you'll have them starting the animations even if they're not in the "attack" state. Aside from that, it should work perfectly

    Tell me how it goes

  • You can't do that in one event. Add the AND condition as a subevent.

    That's the sad truth. It would be nice if it could be done, sometimes this restriction leads to repeating events and actions unnecessarily

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I just noticed that Sprite has triggers to check if animations are finished.

    Just have an instance variable on your enemy object "isCurrentlyAttacking" which you set to 1 when you start each animation, and have a subevent just below the 'enemystate = "attack"' condition to check for "enemy on any finished" with an action to set "isCurrentlyAttacking" to 0. You only start an animation if "isCurrentlyAttacking" is equal to 0

    (I didn't see the condition before because I was testing below another trigger, so it didn't show)

  • I'm sorry, but I don't understand how to write the code you recommended. For my example, would it be something like Add Condition -> Enemy Sprite -> Compare Frame -> Equal to -> "enemykick1" = enemy.5 -1 (I don't know how to write the last bit)?

    That's the condition. Replace Bullet with enemy of course. AnimationFrameCount is an expression that returns the amount of total frames in the current animation of the sprite.

  • If your attack animations don't loop you can have this check along with your enemyattack = x conditions

    enemy Animation Frame = enemy.AnimationFrameCount - 1

    This checks if the sprite is in the last frame of its current animation. However, this may cause the animation to be cut a little short (because the check could come as soon as the last frame starts), so I recommend you pad all of your attack animations by repeating the last frame at the end

  • You could try something like having the Aces to total 11 by default and then using the conditional expression. Let's say you already have the summed total in a local variable called CurrentTotal, and you're just missing the Ace (which you can simply leave for last by ordering cards in the player's hand by ascending value.

    You could do something like

    CurrentTotal = CurrentTotal + Ace.Value > 21 ? CurrentTotal + 1 : CurrentTotal + Ace.Value

  • I believe it's a precision thing. The chance for the enemy's sprite X position to be actually EQUAL to the image point X just when you're checking is pretty slim. You should work with approximate ranges, like so:

    enemy_bbox X < Player_Target.ImagePointX(1) - 2

    enemy_bbox X > Player_Target.ImagePoint(1) + 2

    This checks if the enemy is within a 2 pixel distance from the point. The thing is, you cannot have both AND and OR conditions within the same event, so you will have to use another subevent to check for image point #2, and then either repeat the same actions in both subevents, use a 'isCloseEnough' variable and set it to 1 when the enemy is inside either of the ranges, then do the actions in a subevent with the condition isCloseEnough = 1, or (which I think is the better solution) create a function which takes two X values and a range, returns 1 if they are within the range, or 0 if they are not, and then use System Compare two values like so

    System Function.Call("IsWithinRange", enemy_bbox.X, Player_Target.ImagePointX(1), 2) = 1

    -or-

    System Function.Call("IsWithinRange", enemy_bbox.X, Player_Target.ImagePointX(2), 2) = 1

  • Also the chances that that values match exactly are slim. The usual technique is to use collision or overlap checks, possibly with hidden objects, positioned to the image-points.

    That's normally true, but we don't know exactly how he's handling his movement, so maybe it's just that precise.

    In any case, blackhornet is right, you shouldn't trouble yourself with manual collision detecting, since the engine does that quite well by itself

  • What do you mean with "physics don't happen in the same speed"?

    In any case, another way of doing it would be shooting an invisible ball with the same physics properties as your actual ball a little before, in the same conditions (speed, angle, etc), and check if that one hits.

    The other way would be doing the actual calculations yourself, but that defeats the purpose of having a physics engine.

  • I think your

    "Enemybbox (inverted) X = Player_Target.ImagePointX(1) | Player_Target.ImagePointX(2)"

    condition is written the wrong way

    What you want to do is

    Enemybbox (inverted) X = Player_Target.ImagePointX(1)

    Enemybbox (inverted) X = Player_Target.ImagePointX(2)

    And if you want to invert the whole condition (to check if they are actually touching) you should do

    Enemybbox X = Player_Target.ImagePointX(1)

    -or-

    Enemybbox X = Player_Target.ImagePointX(2)

  • You can do a neater version of the function using the "Array -> For each XY element" condition instead of a nested for, but this way is more efficient because it loops backwards on the array and stops as soon as it finds the last element that matches your search.

    There's a slight problem with this however: this implementation assumes that rows have higher priority in the ordering of elements than columns. This means that in this array

    0 2 4

    3 5 2

    4 2 1

    The 'last' 2 would be the one on (1,2), and so LastYIndexOf(2) would return 2

    While if you gave higher priority to columns, the last element would actually be the 2 on (2,1) and so LastYIndexOf(2) would return 1

    You have to take this into consideration when filling your array. It's not a big problem though, since general convention is to give rows higher priority anyways.

monitz87's avatar

monitz87

Member since 27 May, 2014

None one is following monitz87 yet!

Trophy Case

  • 10-Year Club
  • Email Verified

Progress

11/44
How to earn trophies