Mallets's Recent Forum Activity

  • Would this work even when I have multiples of each? For example, 10 bushes, 10 trees, and 10 flowers?

  • Hello all!

    I'm trying to condense my code and make it as clean as possible.

    I currently have three different objects that display recoil/shaking when shot by the player's bullets. Instead of having three events each with the same set of actions (but each changed to 1 of the 3 objects), there must be a way of condensing it (into a function?). I did try putting the 3 objects into a family and having the function affect the family, but it turns out this affects every member of that family. Here's a more concrete example with sine behavior providing recoil (could be done with shake or other behaviors):

    When sPlayerBullet collides with sTree:

    --destroy sPlayerBullet

    --Store sTree's X and Y positions in instance variables

    --set sTree sine cycle position to 0

    --set sTree sine inactive

    --set sTree sine active

    --set sTree sine magnitude to 3

    --set sTree sine period to 0.2

    --set sTree sine movement to horizontal

    --wait X seconds

    --Set sTree sine inactive

    --Restore sTree to the stored X and Y positions

    The same event is copy/pasted for sFlower and sBush, (but with the correct object) so it's the same set of code 3 times in a row. Is there a way that I can have this set of actions only once in the event sheet for efficiency? Even using function parameters, it seems that I would still have to copy paste the code 3 times, and a simple "or" condition would still have to specify which objects to act on. But ideally, it would look like this:

    When sPlayerBullet collides with (sTree, sBush, or sFlower)

    --Call function "Recoil"

    and then:

    On function "recoil"

    --destroy sPlayerBullet

    --Store tree, bush or flower x and y positions in instances variables

    --(same as above example)

    --restore tree, bush or flower to x and y positions

    Thank you!

  • I think a lot of us are really great at using C2, but I'm sure many people have interesting tricks and tips they use during coding that can make our lives easier. Let's share some of those tips!

      Set up a textbox with debug information, such as your character's speed, vectors, acceleration, etc. Put it on a 0,0 parallax UI layer so you can see it at all times. On player death, set up a textbox to appear saying "killed by X." This has helped me SO many times because it points you directly to the event on the event sheet that is related to the player death. Useful when there are traps in your levels. The "MoveTo" plugin lets you smoothly move any sprite over a distance or toward an object without changing its position every tick (like you would do without the plugin). Make your playable character's stats variables. For example, make his speed "PlayerMaxSpeed," then define this variable in the event sheet. If you ever need to change his speed or let the player upgrade, you won't have to go edit the event sheet line by line. Good for gravity, max speed, acceleration, etc. An easy pause screen event: On press (pause button) -> set time scale = 1-timescale. If it is 1, it'll go to 0 (paused). If it's 0 (paused) it'll go back to 1!
  • As far as I know it have always been like that in C2 and from what I recall have been wanted by users for a very long time. So I wouldn't count of it getting into C2, maybe C3.

    The best thing to do, I think, is to "think before doing" not meant in a negative way, but when you plan a project and you for instant think its time to add enemies. Then the first thing you do is to think project organisation, so you create the folder structure you need, then you create the enemy objects and what you need for them to work (sprites, text etc) and then when you think you are done with them, you drag them to enemy folder. And then you can start with the next thing. If you need to add a lot of the same type of objects, for instant sprites, then you drag the first sprite to the folder and clone it rather than add them through the menu, then it will automatically be added to the folder.

    This is the habit that I've started trying to get into. You're right about planning before acting here! I think from now on I'm going to make "dummy" sprites as the first object in each folder and then whenever I want to make a new object I'll be forced to clone from the dummy directly into an existing folder, rather than uncategorized and piling up at the bottom of the projects tab :-p

  • Hello all,

    I have nothing but praise for Construct 2, but I'm wondering if anyone else has had an experience similar to mine concerning the projects tab.

    When I'm organizing items into folders or categories, I instinctively want to CTRL + click in order to select multiple items, especially if I'm organizing in folders I've just made (Level 3, Boss #2, etc). I understand if the program's coding doesn't allow for multiple selection. But the projects tab doesn't spread horizontally in any of its available views, so I'm dragging one item at a time to the desired folder, waiting for the projects tab to pan up and down each time as I do, since its height is limited to the height of your monitor's resolution.

    I haven't come across any sort of plugin that would allow for this sort of feature, but when a project gets a little complicated with so many different objects, trying to navigate the projects tab can be a little confusing to me. I suppose the best options is to simply collapse all folders you're not working with so that you can see most or all of the projects tab at any time.

    Anyone else also have this experience? If there's no solution currently in place, would anyone else feel that it would make a nice addition to C3?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Wouldn't it be simpler to keep the origin as the center and have another sprite for the death animation?

    Or leave it as is and when you change to the death animation just move the sprite?

    You can use a little math to rotate a sprite around any point if you wish to do that instead.global number centerx= 100

    global number centery= 100

    global number ang= 10

    every tick

    --- sprite: rotate ang degrees clockwise

    ---- sprite: set position to ( (self.x-centerx)*cos(ang)-(self.y-centery)*sin(ang)+centerx, (self.x-centerx)*sin(ang)+(self.y-centery)*cos(ang)+centery )

    Oh, wow. This would do it, huh? I never would have figured this out in a million years, so thank you so much for the explanation!!

  • OR blocks actually pick instances that met any of the conditions. The | operator is simply a logical OR that returns 0 or 1, based on if either operand was true (nonzero). So if you have "health = 7|8", then 7|8 is evaluated as "true OR true", which results in true, which C2 represents as 1, so it's the same as saying "health = 1" which probably wasn't what you intended!

    Wow! This is definitely not what I intended. It's great to have such a welcoming community to get help with this stuff because machine logic just baffles me :-p

  • More than one origin point, huh? Is this different than right clicking in the image points dialogue box and choosing "add image point?"

    I knew you could have multiple image points but I only ever had one origin point. For example, if I choose to do "every tick, rotate BossSprite by 12 pixels," it automatically chooses the origin (or perhaps it just chooses the 0th image point?) I guess my question here, then, is that since there's no way to use the "rotate clockwise" action to say "every tick, rotate by 12 pixels based on image point 1," that there must be another way to do it.

    I'm using the invisible block idea I mentioned above, and while it works, I'm sure there's a simpler way.

  • Hi all, thanks for reading!

    I have a boss sprite with an origin that's "bottom," and for its death animation only, I want it to rotate as if its origin was in its exact center. This way, it doesn't look like it's flipping out wildly in large circles, and instead should rotate smoothly in place.

    My thoughts on this are:

    • Create an invisible block that spawns when the boss dies. Pin the boss to the block upon death and just have the block rotate in place.
    • Somehow change the sprite origin with events, which I don't believe can be done.
    • Some other action commands that can achieve the same goal, such as "rotate around point X"
  • The format is:

    System: Compare two values:

    health = 7 | health = 8

    = Equal to

    1

    Thank you for this simple explanation! One last thing, when you say "equal to 1" , is this a universal "construct 2" thing for being active (or in this case, that the condition is true)? Or is the 1 referring to some project component we need to define ourselves?

  • Hi, thanks for reading my post! I'm wondering if anyone can shed some light on the OR expression using the pipe |.

    I know that we can make an or block inside of a condition, for example, using "health" as a global variable:

    [quote:z7vo2xe1]If health = 8

    OR

    If health = 7

    --> Display 4 hearts on HUD

    But I'm looking at the OR expression and trying to figure out what's different about it. Take the same instance as above, but with:

    [quote:z7vo2xe1]If health = 7|8

    --> Display 4 hearts on HUD

    This second expression, at least from what I'm reading, should return 4 hearts on the HUD if either condition is true, i.e., if hearts are 7 OR hearts are 8. However, I've found that this second example doesn't do anything, so I'm assuming that this pipe expression is actually different from using an OR block in the condition. The construct manual says

    [quote:z7vo2xe1]| is a logical OR operator. These are useful combined with the comparison operators, e.g. score < 0 | health < 0, which also return 1 if true and 0 if false.

    so it sounds like I can get this result using "compare 2 variables" in the system conditions as well, but not the way the second example is shown above.

    Thank you!

Mallets's avatar

Mallets

Member since 16 May, 2015

None one is following Mallets yet!

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies