It's possible to make an object visible while his copy is invisible?

0 favourites
  • 12 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Ay bois, and this time, i'm trying to make a copy of my object be visible, while the original one be invisible, i don't know if it's possible or not, or, if i can do it in another way without creating objects.

    So, i have a sprite called Bar1 and it's the health bar of my enemies. So, my objective is to: When the bullet collides with the enemy, his bar ( not other enemies bars ) shows up. It's the same object Bar1 being visible, while other objects Bar1 be invisible. I tried using container and family ( idk if i used then wrong ), but, i couldn't do what i'm trying.

    If you know how to do it tell me pls!

  • Bullet on collision with enemy, set health bar visible. Should work if they are in a container.

  • Bullet on collision with enemy, set health bar visible. Should work if they are in a container.

    Already tried that but somehow didn't worked, btw, i used family instead of the enemy to optmize my code, so, it's possible to use family and get the same result? Like with another code

  • Hello its really simple, look:

    you need to create a instance variable on that object. when you create a new copy you just have to change that instance variable for something that identifies, for example:

    create new spriteBar

    spriteBar.variable = "player"

    create new spriteBar

    spriteBar.variable = "enemy"

    when you want to hide only player bar:

    system/pick by comparation/ pick spriteBar which SpriteBar.variable = "player"

    ---- > spriteBar set visible to invisible

    so you can pick any copy of the same object identifying it by variables and treat for the most cases as a different object

  • The point is to use the container, the family isn't in the container.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello its really simple, look:

    you need to create a instance variable on that object. when you create a new copy you just have to change that instance variable for something that identifies, for example:

    create new spriteBar

    spriteBar.variable = "player"

    create new spriteBar

    spriteBar.variable = "enemy"

    when you want to hide only player bar:

    system/pick by comparation/ pick spriteBar which SpriteBar.variable = "player"

    ---- > spriteBar set visible to invisible

    so you can pick any copy of the same object identifying it by variables and treat for the most cases as a different object

    Yes, that would be possible, but, there is a way to do it like automatically? Because, whenever is an enemy on screen, the bar is automatically created by the container, not a trigger, so, i don't know if i can do that. My objective is to when the bullet hit the Enemies family, automatically, the bar of that specific enemy shows up.

  • Yes, that would be possible,

    is not that its possible, its the way... and its "automatically"

    but, there is a way to do it like automatically? Because, whenever is an enemy on screen, the bar is automatically

    ... when the bullet hit the Enemies family <--- this is a trigger

    -----> use "on collision", its a trigger event for that specific enemy.

    anyway... I could not solve better without further information, we can help you but to make it that blind its kinda impossible... its better to make a screenshot or even better a capx on drive or dropbox so its simple to see where you are stuck at (this way can be seen your use of family, that can be appropriate or not, etc).

    And by the way, the use of the family or container was not originally a prerogative in your question as far as I can see you said:

    I tried using container and family ( idk if i used then wrong ), but, I couldn't do what I'm trying.

    so based on your words "family" and "container" were two means of reaching your goal...

    in further questions, I would suggest you explain the problem much clear so you will get an answer, this about: "can be done like this, but" "it's not the point" it's not polite when someone uses his time sharing knowledge with you... and then we play that we know more than the other, I have no aim to show I know anything better than you or the other guy, I would be glad if you could help me in my questions about something you know better than me...

    so less show and more try before answer...

    thanks for your time and hope will be useful for the screenshot with an example made in 2 min... if any doubt, don't hesitate in asking. If I understood you correctly this should work for you.

  • Hope this screenshot it's useful for you both

  • Hope this screenshot it's useful for you both

    That's worked for me! Thanks bro, but, i have another question, below is the .capx that i'm trying to create an automatic system for enemies ( like dying, spawning, collisions and more ) to use in my future games, i'm not so good at programming but please, can you review my .capx and tell me where i can optimize and improve my code? Btw, thanks a lot for you help, i really appreciated it!

    .capx: dropbox.com/s/6dt9mv13mwditpn/Sistema%20Morte%20Autom%C3%A1tica.capx

    Sorry for another language in the .capx, and, in the .capx, the way that i was trying to make the bar visible is when the enemy collides with the bullet, or, basically when he gets damaged.

  • Hello again,

    I seen your capx and I advice you to see the capx that are in examples of construct to learn a bit from them...

    there is some nonsense things as you ussing a family for enemigos while is only one sprite object! you do not need a family in this case... if you would have different sprite object then yes... families are meant to control different (same type of object).

    also none of my advice are in the actual capx... maybe you should update it

    if you got google drive and share a folder I can upload a fast version (I do not have much time but can try to help you a bit)

  • Hello again,

    I seen your capx and I advice you to see the capx that are in examples of construct to learn a bit from them...

    there is some nonsense things as you ussing a family for enemigos while is only one sprite object! you do not need a family in this case... if you would have different sprite object then yes... families are meant to control different (same type of object).

    also none of my advice are in the actual capx... maybe you should update it

    if you got google drive and share a folder I can upload a fast version (I do not have much time but can try to help you a bit)

    Hey bro, and, just explaining some things, in my .capx i was planning to add more enemy types, so, to be faster, i already created the code with 1 sprite in the family that would be more easily to edit when i gonna add more enemies type. In the .capx that i've shared, i didn't used your code, it's on the .capx that i'm editing like with some broken codes and more, that's why i shared an old one. And, in the phrase "I advice you to see the capx that are in examples of construct to learn a bit from them..." i didn't get what type of .capx you want to me to see, like in general, i have already studied almost all fo them. And, thanks for helping me bro! I really would like more advices of what you'd say!

  • Hello, well as I said to you better would be to have a google drive in order to be able to post back to you any capx. The capx you posted its not working properly... so what can I advice you there?

    make a google drive..., and complete a bit more (at least work the basic logic you need) and then if you want I can help you further.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)