ScottSto's Recent Forum Activity

  • Looking over the tutorials for family instance variables, they show an example of a "health" variable, and decreasing the value by one when a bullet strikes a member of the family. In my case, I need to set the "IsFriendly" boolean value to "true" for friendly units and "false" with enemy units when a unit is created, then create a condition that checks the value of the "IsFriendly" value when a family sprite is clicked. Is this possible with a family instance variable?

    If not, I believe I can get around this by having conditions for the two friendly units, taking specific actions (like decreasing the player's score instead of increasing it) if a friendly unit is hit, and the normal action (increasing the score) if an enemy is hit.

  • My game has random sprites appearing on the screen using a family. When the user clicks on a family instance, the instance is destroyed and the score increases by 1:

    This works great as long as their are just enemies in the family, Family_NY_2. However, in addition to randomly generating enemies, I would also like to randomly generate friendly units that should not be clicked, and if they are, the score should decrease. Is there a way to do this using families, or would you suggest an alternative method?

  • dop2000, that worked perfectly. Thank you!

  • I have a background that has instances of a "Window" object, and I use the "Pick a random instance" method every few seconds to select one of those windows and have a character object appear on it. This works great, but for one issue. The background scrolls, and sometimes a window that is already halfway off the screen so the user doesn't have enough time to try to destroy that character before it disappears. Is there a way to only choose an instance if it is entirely on the screen?

    Tagged:

  • Currently, I have a game that randomly selects a window (a sprite) in the viewport, and then spawns a "Guy" sprite on the image point of the window:

    This code works. However, I have a half-dozen different enemy images. I would like is to randomly select a window, and inside that window, select a random sprite (Guy1.png, Guy2.png, etc.) What is the proper way to do that?

    Tagged:

  • Thank you so much! That was it - when I had the "Window6" object spawn the "Guy", it worked. And I will take your advice on the layers as well.

  • That was helpful, thank you. I think I am on the right track, but the images I want to spawn are not appearing on the image point on each Window. I have highlighted what I think are the relevant spots:

    So on the image in my first post, those windows are now all "Window6" instances. They are all on Layer 1. I have also tried Layer 0. The result I would like is for the "Guy" sprite to appear on the image point (there is only one) in the center of a randomly selected "Window6" instance. (I have done nothing to the image point - they all have a name of "Origin" and "Number" of 0.) However, nothing is happening.

    What is the piece that I am missing?

  • I had asked a question about how to detect an object in the viewport (https://www.construct.net/en/forum/construct-3/how-do-i-8/detect-sprite-viewport-148001). I have a similar question about how to detect all objects currently in the viewport.

    I have a scrolling background with eight windows visible at any given time:

    I learned from my first question that the "Is on-screen" condition will determine if an object is on the screen. What I would like is, every two seconds, determine which windows are on the viewport. Currently, each window is a separate instance and has "Name" property, though if it's easier, I could just copy so it is the same instance with a different UID value.

    The purpose of wanting to see which windows are in the viewport is to randomly have an image appear in one of the eight windows that is visible. Since the "Is on-screen" is condition, not an event, I'm not sure how to do this without having to hack something together by checking every window. What is a better way to do this?

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you - that was exactly what I was looking for!

  • I have a scrolling background, a building with window. As the viewport scrolls, windows will come in and out of view of the user. I would like images to appear in the windows every few seconds but only if the windows are in the current viewport. Each window is represented as a sprite on top of the background. How do I detect if the current sprite is within the viewport? Thanks!

    Tagged:

  • El Constructorr - thank you, I will play around with the calculation like you had mentioned. That should work if I must keep a grid-like layout.

    Plinkie - I mispoke a bit when I said "random". The backgrounds will be different, so different backgrounds will have different places where the images can appear. But, each background will have different locations, so using my choose() method will not always work, unless I adjust the choose() values for each background and keep the same grid-like structure. I was hoping for something a bit more fluid looking, and that is why I was looking at the image points.

  • I would like to designate certain locations on a scrolling background to appear. The background will only scroll through once, so it will not be repeating. I have made images appear on a static background by using the choose() methods to make the image appear at particular x - y combination, like so:

    choose (100, 200, 300, 400)

    choose (150, 250)

    Using this method, the images appear at the particular spots I want, but the spots where the images can appear can only be in a grid format. I would like to have more variation in the image locations, and I want scrolling backgrounds as well.

    I have briefly looked at image points to designate these spots on a large background image that is several times the width of the viewport, and when that part of the background comes into view, then that spot may receive a new image (randomly selected). Do you think something like that would work, and is there a method to determine if an image point is within the viewport? Or perhaps a different method?

ScottSto's avatar

ScottSto

Member since 2 Sep, 2019

None one is following ScottSto yet!

Trophy Case

  • 5-Year Club
  • Email Verified

Progress

6/44
How to earn trophies