vee41's Recent Forum Activity

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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: scirra.com/tutorials/73/supporting-multiple-screen-sizes/page-1

    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.

  • At least the spawning problem seems to be caused your layout scaling, instead of 'Scale' you should use 'letterbox scale' or similar, take a peek at layout scaling stuff at manual/soem tutorial. Seemed to solve the problem for me at least. I'd imagine the wrapping issue might be caused by this as well.

  • Could you have invisible `collision` sprite pinned to it with position only?

  • For debugging I use chrome log plugin, it simplifies a lot of stuff :-)

    It should not matter if two b instances are destroyed at same time, do you use on destroyed trigger? Posting a capx would allow us to help with this.

  • You could use plugin like easytween or moveto for good looking slide effect, or you could do one yourself with lerp function for example. Those plugins make it really easy so I recommend getting them from plugin forum here :-)

  • Boolean is usually easier to read and makes projects easier to manage, I use them if applicable. I also prefer strings over number states: "walking", "running", "crawling" is 100x easier to read than 1,2,3- describing states.

  • Say you have three objects in a layout. Lets say one is a (slowly moving) bullet type object headed towards a target object. A third object is invulnerable to the 'bullet' and wants get between the bullet and the target to intercept, or block, the bullet and protect the target. How could one achieve this in C2?

    So far I am using the custom movement behaviour for the 'blocker' object for other purposes, so a solution using that would be best.

    Here is my pseudo code solution, but I don't know how to do this in C2?

    * Find the bullet nearest to the target (in case there are more than one)

    * Find the point of intersection between the line between target and bullet and the shortest line between the blocker and this line ( I hope that makes sense)

    * Set angle of motion of blocker to that point

    * Set the speed of the blocker to as fast as possible (limited by an instance variable of the blocker)

    Note that this doesn't anticipate the bullet's motion, so isn't the most optimal solution for the blocker to save the target, but it would be a start.

    I can't find the required information in order to construct a (complex!) expression that could be used to set the blockers angle of motion. How do I determine the location of the closest bullet? The location of the target I can do.

    I know C2 is supposed to be 'programming free' but is it possible to in expressions to create temporary variables in some way? I need to set the blockers angle of motion, but first I need to work out the point to set the motion towards, then do some trig to get the angle. This would be a mighty ugly site as a single expression, even if I could find the required raw numbers to put it together. If I could insert a small 'script' in place of the expression that would be clearest.

    Any ideas?

    * Find the bullet nearest to the target (in case there are more than one)

    (Assuming there is one target)

    Bullet Pick Nearest To Target.X, Target.Y

    Bullet is now picked (check the FAQ thread to see what that means) and you can do stuff with it, like store it's location

    * Find the point of intersection between the line between target and bullet and the shortest line between the blocker and this line ( I hope that makes sense)

    Use Distance(target.x,target.y, bullet.x, bullet.y) to find the distance between bullet and the target, then use mathemagic to take accelarations, speeds and whatevers into account and create a formula to find the desired target X,Y location.

    * Set angle of motion of blocker to that point

    Custom movement (probably) has 'Set angle of motion' action, use Angle(Blocker.x, blocker.y, targetLocation.x, targetLocation.Y) to set it towards your calculated point.

    * Set the speed of the blocker to as fast as possible (limited by an instance variable of the blocker)

    Custom movement (probably) has 'set speed' action to do this :)

vee41's avatar

vee41

Member since 12 Apr, 2012

None one is following vee41 yet!

Trophy Case

  • 12-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

14/44
How to earn trophies