vee41's Forum Posts

  • Here is an quick example I made:

    Fireworks example

  • Using containers would simplify your code a lot. No need to create sparks or pick them separately as they would be automatically created/picked/destroyed with the firework sprite.

  • Hey Vee,

    Thanks for the response. Sorry to sound ignorant, but can you kind of walk me through what each of these lines are doing? I'm a bit unfamiliar with tokencount/tokenat/loopindex/append :P

    Heres an example I made earlier, pretty much the same topic: Selective destroy example

    Hopefully you can see the general idea there, it's quite simple really :)

  • > Instead of having a global variable like that to handle things, why not put the function calls directly at the event that is triggered by the spacebar press?

    Thanks, I tried that and it didn't work <img src="smileys/smiley36.gif" border="0" align="middle" /> I also tried having the variable switch to another number before picking a random number, but it didn't change anything.

    Worked for me:

    <img src="http://dl.dropbox.com/u/19921470/odd_even_fix.PNG" border="0" />

  • That is due trigger once event at 29 and 30. It triggers only once when the conditions are true, so unless the variable changes to another one in between it does not call the function. Instead of having a global variable like that to handle things, why not put the function calls directly at the event that is triggered by the spacebar press?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not really, put them in container and it all works pretty smoothly. :-) I'm not familiar with your particular case of course.

  • Here is an example: dl.dropbox.com/u/19921470/pick_by_index.capx

    EDIT: In your project you are comparing string (the list) to int (index), that is why it fails.

  • Assuming sprite.index is an instance variable you defined yourself, you can do sprite.index=tokenat(..). Its compare instance variable in sprite conditions. If you use uids in your global list, you can do pick by unique id.

  • vee41 - does C2 minify/obfuscate strings on export?

    "Walking", "Running", "Crawling" may be 100x easier to read, but they're 100x less efficient when doing variable tests (i.e. if state="walking" rather than if state=2)

    In most languages, this is exactly why you'd use enums...

    tanoshimi

    I highly doubt there is anything relevant performance in how you do comparisons. To me it's about usability and managing your code. :) The way Ashley has described C2 performance, it should not really matter how you handle simple comparisons as performance bottlenecks are always somewhere else.

  • My code can be explained like that

    Global list = "1,2,4,6";

    for(count= 0 to tokencount(list,","),count++){

       foreach(sprite in game){

          if(sprite.index==tokenat(list,loopindex,",")){

            sprite.destroy();

          }

       }

    }

    My expectation is at least some of sprites must be destroyed. Actually nothing.

    Could some one let me know why.

    Thank to much in advance..

    Do it like this instead:

    Global list = "1,2,4,6";

    for tokencount(list,",")

    pick sprite.index = tokenat(list,loopindex,",")

    .. sprite.destroy

  • That should work, can you post an .capx of the problem?

  • You could do something like this (custom ID set in editor would be safer than using UID's I imagine, they could potentially change between runs).

    GlobalVariable string DeadEnemies = ""

    On enemy destroyed

    .. append Enemy.UID & "|" to DeadEnemies

    On game load event

    .. for 0 to tokencount(DeadEnemies, "|") times

    .. pick Enemy with UID tokenat(DeadEnemies, loopIndex, "|")

    ... Move enemy outside layout, make it invisible or whatever you wish to do to hide it.

  • Here is the code I am using, the initial value for Health is 4 so in theory the final value after destroying all the EnemyTurret_01 should be 0. However, this does not occur when 2 are destroyed at the same time.

    Seems you could do this: add 'for each' loop after health <= 0, OR add 'on destroyed EnemyTurret' trigger where you move the 'pick instance..' - part.

    Also, it seems like your creation method could benefit from containers, or a for loop. You can use loopIndex to pin them to proper imagepoints: Spawn EnemyTurret_01 (image point "Turret_000"&loopIndex) :)

  • I'm not a fan of letterbox scale because it causes black borders to appear. Perhaps this could be changed by adopting a 16:9 aspect ratio? Currently I'm running at 900x600, and letterbox scaling causes black bars to appear.

    Check this tutorial for more info: construct.net/en

    You should probably adapt your game to support multiple fullscreen resolutions if that is your intention.

  • hi, i am new in the forums and in construct 2, so i need help with the behavior of my cheff sprite, if u are below him the green box will try to focus u and the sprite will act like crazy, u can see it in the capx.

    https://www.dropbox.com/s/54ilfgme8vbt1xz/cosa.capx

    someone could help me to fix that?, please.

    pd: sorry for my bad english

    This should solve the problem:

    <img src="http://dl.dropbox.com/u/19921470/Chef_fix.PNG" border="0" />

    Notice how I removed few events, I believe they were unnecessary. :) I also added the '+5' to movement checks, so chef now has a little deadzone where he doesn't try to turn towards player. Smaller value will work as well.