Container and button problem?

This forum is currently in read-only mode.
From the Asset Store
J-BoB Game Button Sound Pack comes with 300 high-quality sound effects
  • Hi, I'm having a problem whenever anything destroyed in the container the rest of sprites in the container are destroyed. Also I'm wondering if there's any other way I could make my player see, since the way I'm doing it now destroys everything in the group. Right now I can't even test my game.

    About the button problem I have this system if you click the sprite it changes a private variable the problem is there is no way to click it again and do somthing else?

    Download Link

  • This is by design. See Containers.

  • So is there any other way I could make my enemy detect if the player is near it?

    Edit:

    Why would someone want all the sprites in the container destroyed if one is destroyed?

  • Also I'm having a problem with making a button, I have this system if you click the sprite it changes a private variable the problem is there is no way to click it again and do somthing else?

    Download Link

  • So is there any other way I could make my enemy detect if the player is near it?

    Edit:

    Why would someone want all the sprites in the container destroyed if one is destroyed?

    Containers, in essence, are used for making one whole object out of several pieces. It's for ease of use when making compound objects. Rays, bullets, and other temporary things that a sprite creates should not be a part of the container.

    If your sprite is spawning sight detectors, they're going to be destroyed. If the detectors are in the same container as your sprite, your sprite will be destroyed also. So the best thing to do would be to not put your sight detectors in the container.

    If you're having trouble linking a sight detector with it's originating sprite, then put some kind of identifying number into a private variable when the detector is created so that you can keep track of it.

    I don't know about your button though, for some reason your cap won't run for me.

  • That seems a bit tedious plus I don't think my way is the best. Would their be a more optimized way to do it?

  • How is that tedious? Dude, it would take like a handful of events to track your detectors that way.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I really don't like using detectors, *ahem*.

    If you want to pick objects that are under a certain distance from something:

    pick OBJECT1 by comparison: Distance(.x,.y,OBJECT2.x,OBJECT2.y) < Z

    should work.

    If you want line of sight, there is a line of sight behaviour which is pretty much self explanatory.

  • How is that tedious? Dude, it would take like a handful of events to track your detectors that way.

    I must of been thinking of a different way of doing it, So how would I do that then?

  • > How is that tedious? Dude, it would take like a handful of events to track your detectors that way.

    >

    I must of been thinking of a different way of doing it, So how would I do that then?

    +For each object enemy.sprite
      -Create a detector
      -Set the detector's "origEnemy" value to enemy.sprite uid
    [/code:14eamw9g]
    
    Then when you do your collision event with the detector:
    
    [code:14eamw9g]
    +Detector is overlapping player
      -Set global value "playerSighted" to detector value "origEnemy"
      -destroy detector
    
    +For each object enemy.sprite
      +UID equals global value "playerSighted"
         -activate your attack routine
    [/code:14eamw9g]
    
    That's just one way of doing it that I can think of off the top of my head, and it's probably not even the best way.
    
    Also, as faggatron said there is a line of sight object you could use, and you wouldn't even need detectors at all.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)