Shindoh's Forum Posts

  • Okay, I've got some good news and some bad news.

    First, it's easy to solve Your problem. Double click Your projectile sprite to open the sprite editor. Now click on the symbol in the top row for 'cropping' the sprite (You don't actually have to do this, but again, it's a good habit for not wasting space, and some other purposes). Then go to it's hotspot and press '5' on Your keyboard's Numpad to center the hotspot.

    Try Your game again, and it will work. Because now, no matter what direction it is facing, it's origin is in the middle of the sprite. It will always be placed similarly, no matter if mirrored or not.

    Second, the actual problem. There seems to be a bug in the Platform Behaviour. If image points are used together with the Platform Behaviour to spawn an object, if the object spawning the new object is mirrored by the Platform Behaviour, it will not only automatically mirror the spawned object according to the spawning object, but also flip it upside down.

    In the case of Your projectile sprite, since Your hotspot is not centered, the empty transparent space between the middle of the projectile sprite and the actual sprite will now be flipped upside down. Now instead of having the empty space on top of the center of Your projectile sprite, it will be at the bottom. Resulting in the projectile appearing slightly lower on the left, when it is flipped upside down (which shouldn't happen anyway).

  • How about You just try to replicate the problem in a completely new .cap.

    I think it's a good habit to, before implementing something new to a bigger project, make the addition work in an empty project file, so You can always be sure, there is no other code interfering.

    That way, if it works, it should work when You implement it in the bigger project, and if it doesn't, then You know some other code might influence it.

    Also, in case You still don't understand why it doesn't work, when You only do this one thing in a new .cap (which also gives You a more clear overview of everything), when You ask for help on the forums, You can just post that new .cap only showcasing the problem.

    And along the same lines, before implenting, meaning, when You test Your idea in a new .cap first, You don't always need to go full on and add sound and graphics. Unless You wanted to test something related to that. You know, don't waste Your time with unecessary things.

    For example for Your problem now, You could just quickly double click the empty layout, add a new Sprite Object, in the Sprite Editor just fill the empty rectangle with some color with the bucket, add a colored dot on one side (left or right), to see which direction it is facing, save. Add another new Sprite, resize it to make it a little smaller, and fill again, save. This will be Your projectile.

    Now You have one big square with a dot (Your Player), and one small square (Your projectile).

    Now add Your MouseKeyboard Object and add the least necessary Events to do what You want to do: Turn left, turn right, shoot projectile according to the direction Your Player is facing.

    That'd just be about 3 Events, and everything together should just take You about 5 minutes to create, and You'd know if it works or not.

    Usually, You don't even have to rewrite the Events, when You want to add them to Your bigger project. For this to work, You just need to rename all the used objects in Your testcap to the same names they have in Your game. And if You added variables that the objects don't have in Your original bigger project, You just need to add the new variables to the related objects in Your game.

    Then You just select all the Events You want to copy from Your testcap, right-click on any of them and click 'copy'. Then You go to Your games' Event List and right-click paste them.

  • put the enemy in a family

    we'll call the enemy sprite Badguy, and the family Blue, and your nearbyness radius we'll call Radius:

    Badguy-sees Player

    ---Blue-Pick by comparison-distance(Blue.x,Blue.y,Badguy.x,Badguy.y) less than Radius

    ------Blue chases Player too

    Now that's very elegant. lol

    I was thinking of using distance() too, but I just couldn't get around the problem with the picking, since 'Badguy Sees Player' is already picking.

    But using families is like referencing instances of a new object, so it works. Brilliant.

  • You could easily make a visual solution for this.

    You just create a circular sprite with Your desired radius, which You will make invisible, and create and destroy when necessary. Let's call it RadiusDiscSprite.

    +For Each Enemy

    + If Chase = 1

    SUB+ Trigger Once

    -> Create/Spawn Object (RadiusDiscSprite, At Center of EnemySprite)

    SUB+ Always

    -> Set RadiusDiscSprite.Position to Enemy.Position

    + For Each Enemy

    + Enemy Overlaps RadiusDiscSprite

    + Trigger Once

    • > Set Chase = 1

    + For Each Enemy

    + Whenever Your Event sets Chase back to Chase = 0

    + RadiusDiscSprite: Pick By 'Closest to Enemy' (Or Position = Enemy.Position)

    + Trigger Once

    • > Destroy: RadiusDiscSprite

    I'm sorry, I don't know why indenting in my post doesn't work?

  • Is there any way of inserting a string into a string variable at a defined place in the text, an index maybe, without having to set the text to left(stringName, stringLength) & "addition" & rigth(stringName, stringLength)?

    I don't want the CPU to count the right side of the string over and over again, which is what I am doing right now, with a lot of different strings at the same time and GetToken(), with an increasing index position going over 2000.

    I have events checking for and reading the current index position in a string, and if a certain string is given, do something according to that string at that position.

    About 3 Events for this keep checking every tick and for multiple (about 10) strings at the same time each tick.

    With increasing index value in GetToken the FPS breaks in.

    My idea was then to just after maybe every 500 Tokens (index 500), add a NewLine, and restart the index to 1, and keep reading the text in the New Line, starting from index 1.

  • Here's an example: http://www.filedropper.com/angleupdateexample

    This will adjust the angle of the sprite according to the current movement angle.

    I'm sorry it took so long, but I'm in China right now, and almost every foreign file/image/video upload as well as streaming website is blocked here.

    I also only just now saw Your terrain sprite. Are those small pixels floating in the air near the terrain also part of the terrain sprite?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have no crash, but for me just switching to a given Layout with the press of a button doesn't work.

    Just make an empty cap, two layouts. Each Layout has its own Sprite object (different positions and colors, for easier differentiation). And a global MouseKeyboard Object.

    + On 'Space' pressed:

    -> Go to Next Layout/Switch to Layout Nr.(either behaves the same)

    I have one of this Event on each of the two Layouts:

    + On 'Space' pressed:

    -> Switch to Layout Nr.

    However, every time after the application has been started, the first press will always only reload the current layout, each consecutive press works as expected (according to Events).

    No transition picked.

    EDIT: Nevermind. It seems that had to do with the MouseKeyboard Object being global and checking on each Layout at the same time for some reason? I don't know, still weird actually.

    But the reason I say that, is because when I changed the Button in one of the Events to another, it worked right away.

    But shouldn't the Events of a Layout only be checked, if it is the current Layout? And not because there is a global Object inside an Event?

    Still it doesn't make sense, because even when I made a new MouseKeyboard Object for each Layout, it behaved like this.

    2nd EDIT: Okay, here's what I found out now. It has nothing to do with the MouseKeyboard Object being global. It is indeed the Layout Switch making trouble. The first time You make a layout switch after application start, it will in fact read switch to the other Layout AND continue reading the Events of the new Layout in the SAME Tick. It will add the Events of the new Layout to the current Tick.

    The next time You switch Layouts, it works as expected.

    You can check this by switching the layout upon a button press, and increase a global variable by one.

    Now on the second Layout, for the same button press, You switch the layout back to the first, and increase the same variable by one.

    If You now press the button the first time, the variable will increase by 2, after that each consecutive press will just increase by one.

  • Am I doing something wrong, or why does it only go to the next Layout (or Layout of given Number), after pressing a button the second time?

    I made a new empty .cap. Just to check for switching between Layouts.

    When pressing Space, it should change to the next Layout.

    Now what You see is this:

    1) Space Pressed - Reloads same Layout

    2) Space Pressed - Loads wanted/next Layout

    3) 4) 5) ... Space Pressed - Works as expected.

    But every time the first press (after running the application) reloads the same Layout.

    2nd EDIT: Okay, here's what I found out now. It has nothing to do with the MouseKeyboard Object being global. It is indeed the Layout Switch making trouble. The first time You make a layout switch after application start, it will in fact read switch to the other Layout AND continue reading the Events of the new Layout in the SAME Tick. It will add the Events of the new Layout to the current Tick.

    The next time You switch Layouts, it works as expected.

    You can check this by switching the layout upon a button press, and increase a global variable by one.

    Now on the second Layout, for the same button press, You switch the layout back to the first, and increase the same variable by one.

    If You now press the button the first time, the variable will increase by 2, after that each consecutive press will just increase by one.

  • > I don't really know the Physics Behaviour that well, but from what You are saying, it sounds like moving up a slope is no problem for You? Just adjusting the angle of the Player Sprite itself (the rotation)?

    >

    > You can easily do this by comparing the LastX and LastY (private variables, that You assign the .X and .Y position to, at the end of the Event Sheet) position with the current .X and .Y position, by entering the values into the angle expression (a system expression).

    > It will then give You the angle the Player is moving in; You then just set the Player Sprite Angle to this.

    Can you please explain this more detailed or make a cap? <img src="smileys/smiley11.gif" border="0" align="middle" />

    Okay, the basic idea behind finding an angle is having two points at different positions.

    Imagine a coordinate system, a graph. Now You enter a point at (5, 5) -> (X, Y). The point is at 5X and 5Y in the coordinate system. Now let's make a second point at (10, 10). It should already be obvious when looking at this graph, but then You connect the two points.

    Now relative to the X and Y axis, that means, when You compare the line You just drew to the X-Axis and the Y-Axis, it will be 45 degrees.

    You could get the same result, by entering a point at (0, 0), and (1, 1), this would also equal a 45 degree angle.

    So what we need first is two points to compare, the last position, and the current position of Your object. In the current tick (the current frame of the game), how do we get the last position?

    First we give our object two private variables, a LastX and a LastY variable. Then we need to assign them. Now we want to have the old value, before any new movement is added in the Event List.

    If You were having Events further down Your Event List, that move the Object, we could just assign the current .X and .Y position to LastX and LastY at the top of the Event List.

    See it this way, the Event List is checked from top to bottom.

    Now, it will first fill the LastX and LastY variable with the current .X and .Y (let's say 5X and 5Y), further down You have an Event moving the object to the right (X+5) and up (Y-5). So now the current .X and .Y position in this frame, this tick the Event is checked, is 10X and 10Y, while LastX and LastY are still 5X and 5Y.

    So below the Event for movement, we can now compare the two. Because LastX and LastY will only be assigned again in the next frame/tick of the game (at the top of the Event List). But in the current tick, it hasn't been changed yet.

  • I don't really know the Physics Behaviour that well, but from what You are saying, it sounds like moving up a slope is no problem for You? Just adjusting the angle of the Player Sprite itself (the rotation)?

    You can easily do this by comparing the LastX and LastY (private variables, that You assign the .X and .Y position to, at the end of the Event Sheet) position with the current .X and .Y position, by entering the values into the angle expression (a system expression).

    It will then give You the angle the Player is moving in; You then just set the Player Sprite Angle to this.

  • Unless I am missing something, why don't You just use a 'focus' variable?

    Set it to 1, if You want focus, and to 0 if You don't.

    Then only allow the buttons to work, if something was pressed AND focus = 1.

  • (event 70)

    + Hero: On collision between Hero and BibleDrop

    -> System: Add 1 to global variable 'BookCount'

    -> BibleDrop: Destroy

    (event 71)

    + System: Is global variable 'BookCount' Equal to 66

    -> System: Add 2000 to global variable 'Score'

    -> System: Set global variable 'BookCount' to 0

    -> Hero: Set animation frame to 2

    (event 72)

    + Hero: Animation frame Equal to 2

    (event 73)

    + System: Every 5000 milliseconds

    -> Hero: Set animation frame to 1

    Okay, according to my logic what should happen with this is:

    When 'BookCount' is 66 the animation frame will be changed to 2. (note animation frame is not another animation, but the second frame of the current animation)

    Then in Event 73, Every 5 seconds, we set animation frame to 1. (note again, not the animation, but the frame of the current animation)

    What we should see with this code, is the animation "frame" changing to the second frame one time, once 'BookCount' is 66, and then never change back to frame 1.

    Because Event 73 is only run every time if in the same frame/tick: "Hero Collides with BibleDrop AND BookCount = 66 AND Hero Animation Frame = 2. However in the next tick, the Event check already can't get down to Event 73, because Hero must still be colliding with Bible Drop and BookCount must be equal to 66.

    From my understanding, You should better use the Every X ms as a main Event, combined with a constantly true condition (or at least true for longer than the 'Every X ms' You entered), like a variable.

    7Souls way is a good suggestion.

  • Is (Event 73) a Sub-Event of (Event 72), or one of the Main Events?

    If it's a Main Event, then that's Your problem.

  • INI writes to disk, and you should never constantly write to disk like that! It's far too slow to be practical. You should only save to INI once, like at the end of the layout, or when the user clicks save. Hash table is all done in memory so there's no slowdown from going to disk at all.

    Thank You, Ashley. <img src="smileys/smiley1.gif" border="0" align="middle" /> Gives me some clues as to what to research next, the difference in disk memory and RAM, and how exactly they work.

  • Could someone explain to me why writing to an INI file every step (adding string) slows down the application significantly, while doing the same thing with a hash table causes almost no change in Framerate?

    The string added every step is basically just the number of the .X position of a sprite and a comma.

    The Framerate doesn't drop instantly either (testing in Unlimited FPS mode), but after a while. So I thought it might have something to do with the INI file getting too large? And that every consecutive time it needs to search longer for the end-position to to add the next string to.

    Thank You in advance.