Shindoh's Recent Forum Activity

  • Okay to solve that, You just need to filter the "picked" instances of the Bullet Sprite.

    You could add an Event in the Always SUB-Event of Right Mouse Button Down:

    Bullet.Pick By Position = Samus.Image Point.

    OR

    Bullet.Pick By Closest To(Samus.ImagePoint or Position)

    Also note, that the Always Event I put is NOT in the same SUB-Event as the Trigger Once Event. It's a seperate SUB-Event of the "Right Mouse Button Down" Event.

    So it would be something like this:

    + Right Mouse Button Down:

    ++ [Trigger Once]:

    --> Create Bullet at Samus(ImagePoint)

    --> Set Bullet.Speed = 0

    ++ [Bullet.Pick By (Position = Samus.ImagePoint OR Closest to Samus.Pos) ++ Always]:

    --> Set Bullet.Position to Samus.ImagePoint

    --> Set Bullet.Angle to Samus.Angle

    + [Right Mouse Button Released: + Bullet.Pick By (Position = Samus.ImagePoint OR Closest To Samus.Pos)]:

    --> Set Bullet.Speed = 500

  • Without seeing the .cap, I'd say You're just missing this:

    Right Click pressed DOWN

    Trigger Once:

    ->Spawn Bullet samus (@Cannon Point)

    ->Set Bullet Speed 0 (Keeps bullet still)

    >>Always:

    ->Bullet: Set Position to another Object('Samus', 'CannonPoint')

    ->Bullet: Set Angle = Samus.Angle

  • There are two things I see up front.

    The first is, You add 1 to the 'Shields' variable, instead of setting it to 1, when 'Bookcount' = 66. And You only set the Frame to 2, if 'Shields' = 1.

    Why is this a problem? Well, if we think ahead. Then what will happen, if 'Shields' = 2? Which will happen, because You always add 1 to 'Shields' for each 66 Bookcounts. Of course right now nothing will happen if it's 2, but You never set back 'Shields' = 0.

    And You say if 'Shields' = 0 -> Set Frame to 1.

    Also the Sub-Event code for "Every 15000ms" will only run, if 'Shields' = 1.

    The next things is, the short flash You see. Why? Think about it again. When do You set Frame = 1? If 'Shields' = 1 AND "Every 15000ms".

    So this Tick let's assume 'Shields' = 1 AND "15000ms" have passed in this Tick. In this Tick Frame will be set back to 1. However the next Tick the 'Shields' = 1 Event will be checked again and what happens if 'Shields' = 1? Set Frame 2.

    It can be maddeningly frustrating at times, but stick to it and with time You will get the hang of it. You know, every beginning is hard and all good things take time. It's also important to keep a cool head and try to keep a good overview and memory in Your head of the processes going on at all times, that might be related to other.

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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.

Shindoh's avatar

Shindoh

Member since 24 May, 2011

None one is following Shindoh yet!

Trophy Case

  • 13-Year Club

Progress

13/44
How to earn trophies