AllanR's Forum Posts

  • Solomon - another way is to use a global variable:

    On Start of Layout B --> set NextSpawnTime = Time + 5

    then, instead of every 5 seconds:

    System Compare two values ( Time >= NextSpawnTime ) --> spawn box, and set NextSpawnTime = Time + 5

    The only thing to watch out for is if you pause the game (or open a settings menu, or display a message) - you would have to save the remaining wait time:

    TimeToSpawn = NextSpawnTime - Time

    then when you unpause, set NextSpawnTime = Time + TimeToSpawn

  • ij3m

    Like Taser said, gravity is already build in to the Platform behavior. You can change its value in the properties panel, or at run time (if you want stronger or lighter gravity, you can also change the Angle of Gravity). The default value is 1500. As long as there is a value for gravity, everything will happen automatically. There is no need to do anything in the OnJump() event (other than change animations, or things along those lines).

  • give your object the Sine Behavior...

    (you would have to post a .capx file for any one to test it out. the caproj file is only some of the code - not enough to open and test a project.)

  • Solomon

    do the layouts share the same event sheet?

    there is an event "On Start of Layout"

    I had a similar issue that I thought might be some kind of bug, but turned out it was an error in my code. So, I would think there is something you are doing that is causing this - and it is impossible to say what it is without seeing your code.

  • jeebroniz

    in the Add Action window for an object, down at the bottom is a Z-order section.

    you can move an object to the top or bottom, or move it next to another selected object (in front or behind).

    Those functions should give you the ability to easily order your objects any way you want, The For Each (Ordered) performs extremely quickly for me, so it could be some other factor that is killing your performance.

    Every object has a Zindex value you can access directly to figure out its depth - there are lots of ways to make it work.

    like I said above, the main trick is to avoid ambiguous situations when comparing one object to another of the same type ( object.Zindex > object.Zindex doesn't make sense because C2 can't tell which specific instance is which). So, you have to pick the first object by the type, and the second one by a family (so you end up comparing object.Zindex > familyObject.Zindex) those could be any two instances you want, but now C2 knows which one is being compared to another of the same type,

  • rekjl (and jeebroniz - C2 can do exactly what rekjl wants using built in Z-order functions)

    It doesn't work to compare an object to others of the same object type directly - so what you have to do is make a family and put your object in that.

    then, when you click on an instance of your object, you can test to see if any FamilyObjects are overlapping. you can use PickCount to see how many there are, and you can loop through them to see if their Zindex is greater than the original object's Zindex to know if any are on top of it.

    one other thing to watch out for is the initial click could click on several instances of the object if you had a bunch in one spot. So, use the "Pick Top/Bottom" (and select top) to get just the one object you want, then look for overlapping family members.

  • franknitty2 - the line of code that is deducting health is probably running multiple times. You might need to add a trigger once condition or have some other way to stop taking further damage for a short period of time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • JeremyBenson11 - well, I was just telling you it is not a bug in C2. The Line of sight behavior uses Solids as obstacles (unless you use custom obstacles). Since your object had the solid behavior, it was considered an obstacle, and therefore your player did not have line of sight to it. That is why the click did not work - not because there is a bug with mouse clicks on solid objects, but because your player did not "see" the object even if it was 5px away. (the "player unit has line of site to enemyUnit.X, enemyUnit.Y" was false, and that stopped the code from executing).

    removing the solid behavior was the correct fix, but the issue was the conflict between trying to see something that was obstructed, not because of a bug with mouse clicks in C2. (although, you could argue that line of sight should be able to "see" the obstructions - unless they are obstructed by something else. but that would be a feature to request)

  • Hi...Any idea ?

    I would give the ball an instance variable called something like "InSand"

    then if it enters the sand area, and the InSand variable is false, set it to true. (and set linear damping accordingly)

    then when the ball leaves the sand area and InSand is true, then set it back to false.

    that way you don't need trigger once, and having multiple balls wont make a difference. Once the variable is set properly, the code wont run again.

  • imothep85 you could use smaller invisible sprites at different parts of the tunnel and check those for collisions or to give the player the ability to fly...

  • Cam112549 - yeah, dropbox seems to be having trouble right now.

    Doesn't 8 direction already take care of mirroring? I don't think you have to manually do that...

    There could be a number of things going on: if your code checks for the right arrow first, then the left arrow, then if both keys are down, the left arrow will be processed last, so your sprite will end up mirrored. So, checking left first may improve things - but then you would have the same issue going the other direction.

    when your sprite is moving right, its 8direction.vectorX will be poitive. So you could set your sprite to mirrored only when both the left arrow is down and the 8direction.vectorX is negative. That way pressing left arrow to stop the motion wont make your sprite mirrored until it actually starts moving to the left.

  • JeremyBenson11 I doubt it is a bug in C2 - probably factored into line of sight, or maybe it was stopping the projectile. There is almost always an explanation - sometimes finding the reason can be difficult (and frustrating).

  • martinx09

    Ashley wrote a tutorial for this: https://www.scirra.com/tutorials/73/supporting-multiple-screen-sizes

    and I have seen templates that show rectangles for various resolutions that you can use as a guide to know where safe zones are that will always be on screen, and where you have to make sure you have enough background to cover unusual screen sizes.

    It is a common problem. It is up to you to decide how you want to handle it. It does sound like you want to do scale inner. Parallax can be an issue - UI layers should be set to 0,0 and you have to make sure import things are always visible on every resolution you want to support (always in the safe zone). You can use the Anchor behavior, or you can make a "camera" sprite with the scroll to behavior, or various other techniques to keep the desired parts of your game on screen.

  • Cedriking

    Yep, korbaach is correct. You should only have one else. Because the code executes EXACTLY the way it is written.

    If you read it through, you will see it first either sets it to the hand or normal for the AlertClose, then it will set it to the hand or normal for the AlertCancel, then it will set to the hand or normal for Rooms, then it will set it to the hand or normal for AlertAccept.

    So, if the mouse is over AlertClose, it WILL set it to the hand, but then the next three sections of code will all set it back to normal, because it will execute the three else clauses below the AlertClose block... (same goes for the AlertCancel and Rooms code). Only the last block doesn't get undone.