2 Problems: Loop

0 favourites
  • 8 posts
From the Asset Store
For Adventure, Action, Heroes, Sci-fi and Action-RPG games.
  • Hi all, i couldn't figure out how to use loop correctly for each enemy patrol.

    There 2 problems

    1- How to create shadows for each sprite using loop and stop loop when it's done to all sprites have shadows now? I did it but, it appears it won't stop creating objects and causes performance issue.

    2- How to fix the wrong angle of motion frames and stop imitating the same frame to sprite #1?

    It seems a sprite number #1 does the direction of patrol was correct, besides they were incorrect.

    There a .capx

    http://dl.dropbox.com/u/76227787/MistakeLoop.capx

    Thanks!

  • 1. The system compare condition does no picking so place events 2-5 as sub-events of a "for each Patrol".

    2. Duplicate the shadow object in the layout so you have 3 instances. Replace event 6 with:

    +Every Tick

    --- Shadow: set position to Patrol

  • 1. The system compare condition does no picking so place events 2-5 as sub-events of a "for each Patrol".

    2. Duplicate the shadow object in the layout so you have 3 instances. Replace event 6 with:

    +Every Tick

    --- Shadow: set position to Patrol

    It worked!   <img src="smileys/smiley1.gif" border="0" align="middle" />

    Thank you a lot!

    Does there no way to generate shadows according to how many enemies on a layout?

  • Also, i would like to know one more thing, how to make every patrols to wait for 2 or 4 seconds what they choose time before to move? i wouldn't to see these patrols walk in synchronization, it must be desynchronization.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can create the shadows with events. For the method I gave you just make sure that the number of shadows matches the number of patrol. If the number is less create another, and if it's more delete one.

    Another method would be to use an instance variable in the patrol to keep track of the UID of it's shadow.

    You can make them move out of sync with a Boolean instance variable and the wait action:

    +patrol: is NOT patrolling

    +for each patrol

    --- patrol: set patrolling to true

    --- wait random(2,4) seconds

    --- patrol: set angle of motion...

    --- patrol: set speed...

    --- wait 1 second

    --- patrol: stop

    --- patrol: set patrolling to false

    Of course you could alternatively use a variable to make a timer.

  • You can create the shadows with events. For the method I gave you just make sure that the number of shadows matches the number of patrol. If the number is less create another, and if it's more delete one.

    Another method would be to use an instance variable in the patrol to keep track of the UID of it's shadow.

    You can make them move out of sync with a Boolean instance variable and the wait action:

    +patrol: is NOT patrolling

    +for each patrol

    --- patrol: set patrolling to true

    --- wait random(2,4) seconds

    --- patrol: set angle of motion...

    --- patrol: set speed...

    --- wait 1 second

    --- patrol: stop

    --- patrol: set patrolling to false

    Of course you could alternatively use a variable to make a timer.

    Ok, i tought loop system can automatically generate quantity of sprites to each other sprites on the layout, actually it doesn?t and we should to do manual way like copy each sprite for other sprites.

    I implemented with your method about patrol and it worked like a charm. Thanks!

  • try a 'on create' event for your patrol and make it make its own shadow object. Then every time a patrol is created itll make its own shadow without you havin to keep up with it. Just make sure you store the shadow object thats created with an instance var for that patrol so when the patrols deleted it can delete its shadow in an 'on destroy' event

  • try a 'on create' event for your patrol and make it make its own shadow object. Then every time a patrol is created itll make its own shadow without you havin to keep up with it. Just make sure you store the shadow object thats created with an instance var for that patrol so when the patrols deleted it can delete its shadow in an 'on destroy' event

    I've created another event "on destroy" with Pick nth, Instance patrol.IID that automatically destroys the shadow container according to ROJOhound's container from CC code on C2.

    Also im curious about "On Created", would you like to make an code example? i'm sorry is quite hard to understand due to logic verb.

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