Stone-4's Forum Posts

  • Ok here is a Youtube video to how I generate random instances if you don't understand the line of codes below.

    Create a GROUP called "Call ran Function 1" Duplicate this group and have the second one disabled on start. The reason is to ultimately prevent the error of have 0 layers visible to the player by following the rest of this guide! It will hopefully all work for you if you follow every line step by step. Private message me or hope somebody has a more condensed way of doing this. It's all problem solving, but hopefully I solved all of the potential problems in this post.

    Here is the Random Event lines of code to put into the both Call Random Function Groups. Make sure to set the second one inactive on start.

    on Function "ran" / Set Return Value floor(random(Function.Param(0),Function.Param(1)+1))

    * I don't know how often you want every layout to change, but here's an example of the next line of code

    Every X Seconds (5 seconds)/ Call Function "ran" Paramater (1,4) *This number is the number of layouts you have. If you have 20 layouts then set the first parameter to 1 and the seconds parameter to 20. When you press done in Construct 2 it will look like Call Function "ran" (1,20)

    *Now your return values are changing between 1 through 20 once every 5 seconds randomly.

    Create Events like this for all 20 Layouts

    *Do not use Function Return Value condition I had problems with it and System/Compare Two Variables does the same thing in theory and worked for me so use that.

    System- Compare Two Values - Function.ReturnValue - Equals - 1 - Layout 1 is visible - / System - Go to Layout 1 - Wait 6 seconds set Layout 1 invisible ELSE Toggle group "Call Function ran" 1 Toggle Group Active"Call Function ran" 2 /call function "ran"/

    (or whatever you choose to not collide with your random timing) * This way when the random Function calls Layout 1 again it will be invisible. I am guessing once the layout is gone it never comes back until the game resets)

    **** TOGGLING THE GROUPS will prevent you from ever having both on or off at the same time.

    System- Compare Two Values - Function.ReturnValue - Equals - 2 Layout 2 is visible / System - Go to Layout 2 - Wait 6 seconds set Layout 2 Invisible ELSE Toggle group "Call Function ran" 1 Toggle Group Active"Call Function ran" 2 /call function "ran"/

    *Repeat this step for all layouts when the layout is set to invisible it will not be called because of these events and giving it the effect of being destroyed or at least unable to be called.

    So you will have to create a lot of events if you have a lot of layouts but that is the simplest way I would go about doing it. If you understand arrays, parameters, or different types of variables you may find a quicker way to do this.

    Doing these will pick a random return value every 'X' seconds and when the return value is selected it will go to layout number 'whatever' and then when the next 'X' seconds passes you will have made an action 1 second longer than the X seconds so that the previous layout goes invisible and since in the one event you put Layout 'whatever' is visible even when the random event is called it won't go to an invisible layout. ** The worst result is that a layout might be on the screen longer when you toggle the groups active and inactive, but at least you should never get invisible layouts.

    **Make sure you space out everything apprpriately. You should get how I am thinking it's pretty simple then be able to adjust the seconds between accordingly. God bless you!

  • ]There are 3 of the same sprites on the screen and I am doing a command System: Pick Random Instance of Object, On Function Call - Create Fire at Object.ImagepointX(1), Object.ImagePointY(1)

    3 more events just like this with image points 2,3,4 as well.

    When I press play they all create the fire sprite at the same time instead of only at one random instance of the 3 objects.

    I would upload an image, but it seems that option is gone

  • Xavier

    Yes thank you I will use the particle method!

  • I am bumping this question I had forgotten to give it a title other than How do I at first and I edited it to be more specific. I'm trying to make this dash animation/effect follow a circle in all directions it can travel, which is 360 degrees. It's a super simple game my friend and I are making so this small detail is holding us up. Thanks for your help Scirra members!

  • I've been looking through the effects that C2 can generate and have not yet found this. How to make an object show a cool dash animation in any direction it travels.

    Similarly how to make it's trail behind it glow like a comet's tail.

    Thanks for the help. I'm sure this is a simple question.

  • THANK YOU SO MUCH! IT WORKS Here it is ramones's triangularOrbit.capx edited to do exactly what I want!!!

    THANKS for the polygon examples as well!! I've been stuck on this for like a week or so! You've added simplicity to the code and ideas for my project thank you so much!

    Now I have the circle, square, and triangle. Side to side is easy just use set position. Thanks everyone. I can now create cooler shapes just by having these basic ones!

    Thanks to all the people who helped with this case! Kyatric and brunopalermo! I hope God blesses you!

  • Kyatric

    I'm glad it isn't just me. I got kinda close. Thank you for this example.

    brunopalermo

    I hope you have time to make it dynamic. I will work on fusing my close attempt with Kyatric's in the mean time.

    I tried creating a right triangle so I could fuse two right triangles into a equilateral triangle, but that was glitchy.

    I also had a point that the square would follow appear and used Move To command, but then when I moved the center it fell off the path even though it made a triangle standing still.

    When this problem is solved I would love to put the circle, square, and triangle examples that behave the way we are aiming for relative to the center in a tutorial or frequently asked questions!

  • I'm still looking for the answer to this. I couldn't use brunopalermo 's example because his moved without being relative to a center object.

    In my capx examples in the first post you can click and the center object follows as well as the path perfectly around the center following where ever you click.

    Pathfinding does not work for this type of movement.

  • How? Where's the center in the code?

  • This isn't like the capx examples unfortunately. In the examples the motion is in relation to the center object, which moves and as it moves the motion path stays relative to the center.

  • I have been trying to create a series of orbits around moving centers where an object moves in a path relative to a moving object's position. I have a perfectly working circle and square motion from users from this site that work how I want all of the motions in my project to work.

    The examples are attached.

    This time I want a triangle motion that is just as smooth. I've tried path finding and I don't know how to edit JohnnySix's [attachment=0:wifh08tj][/attachment:wifh08tj] example to make a triangle. I'm smart, but I only had a highschool physics class and haven't gone past pre cal so no I don't really understand how to create a triangular motion like these examples. I've spent at least 4 hours on the circle motion, 2-4 hours on the square motion, and definitely 3-4 hours on the triangle motion. I almost made the triangle motion, but my best try won't stay on the triangle's path when I move it. I will keep trying, but please help if you can make a triangle motion that moves like the circle and square example!!!

  • I'm not the man xD. I give glory to God, Jesus Christ, that I was able to help you. I just figured this stuff out within the last week. I'm also building an endless runner type game for the first time. I hope to launch mine over several platforms with the diversity of Construct 2. God bless you on your endevors.

    Please pm me if you have any other questions since we are building the same type of game we are probably running into the same problems xD.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "Fixed Path" or "Travelling at Offset"

    Fixed Path is a position behavior that would work to create a fixed path that is positioned based on offset to a moving object.

    (Pathfinding only works well for paths that don't constantly move)

    This action would take these inputs:

    Direction: (360-0 degrees)

    Offset of What object:

    Travel what direction

    (angle input)

    at what offset - How far in position to the object away

    for how many pixels?

    Able to accept repeat how many times (default loop)

    Those last few steps would then be called point A.

    You could add up to 8 points.

    I am having the hardest time moving things along a path that moves relative to a center object.

    Path finding remembers old destinations and doesn't maintain a fixed path. Now here's a capx example of what I want this action to do. http://johnnysix.net/games/sqpi/sq.capx Without this capx example I'd probably still be stuck trying to get a square orbit around a moving center. All the credits to JohnnySix for that capx

    I don't know enough to go through the trouble of figuring this stuff out on my own. I've been trying to do a triangular motion that's just like this for hours. This behavior would save a ton of trial and error time.

  • Oh I've done this before.

    As you can see I just used the overlapping at offset condition. so when center is overlapped 100 pixels to the left of it the score increases by 1. You can use this condition multiple times to have many places where the object can be overlapped at offset.

    Don't forget you can use negative numbers for hitting the left and the right of the object (at offset).

  • Lordshiva1948 JohnnySix

    I was able to get the download JohnnySix gave. it is perfect! Thank you all so much!!

    Case SOLVED