Creating Delayed Object Highlighting

Get help using Construct 2

Post » Sun Aug 04, 2013 10:22 am

In my program, the computer will spawn units after the player spawns units. The computer spawns units one at a time, similar to the player. This aspect of the game is working well.

I want to have the spawn area the computer is focused on to highlight. Right now, every spawn area the computer can spawn a unit on will be highlighted during computer spawning as opposed to one at a time (run the game to see what I mean).

Here is the relevant code:



Any help or ideas would be appreciated.

BoardGame.capx
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Sun Aug 04, 2013 12:09 pm

I've done some more testing and decided putting a loop inside a function isn't going to cut it. If I just wanted to have delayed spawning without highlighting, this would have worked just fine, but since I effectively need a delay on two items at once, I think not using a loop is more effective.



This is what I have now, and it seems to work much better, although it's still not quite what I'm looking for. I've updated the .capx as well.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Sun Aug 04, 2013 1:45 pm

Another update. This is very close to what I'm looking for, although I'm still not exactly sure why the second and third spawns are much shorter in time than the first spawn.



The .capx has also been updated.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Mon Aug 05, 2013 4:06 am

Would like to bump this since one of the math wizards (@r0j0hound) seems to be on :D

The problem: After the player spawns his units, I want the computer to spawn its units. Computer spawning is working, but I'm trying to control the timing so that the computer doesn't spawn all of its units at once but instead sequentially with a slight delay between each spawn. This is made difficult by the fact that I want the currently spawning area to be highlighted.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Mon Aug 05, 2013 4:49 am

One idea that may make it a bit easier to control is to only let the "ComputerProgramSpawn" function get called when not waiting.
1. Create another local in the "computer spawning" and call it stall.
2. Add to event 48 a compare stall=false
3. And change the wait in event 52 two three events:
set stall to true
wait 1 second
set stall to false
B
92
S
32
G
106
Posts: 5,272
Reputation: 69,455

Post » Mon Aug 05, 2013 4:54 am

@R0j0hound

This definitely seems to work!



The other problem I'm having is the highlighting synchronization. The highlight on the first spawn works perfectly, but after the computer spawns its first unit, the other two spawn areas start to highlight even though the spawning only happens one at a time. Any ideas on how to synchronize the two?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Mon Aug 05, 2013 8:30 am

I've updated the .capx to include a debug counter.



The reason why the computer's second and third spawns are much faster than the first is because the ComputerSpawn variable rapidly goes from 2 to 3.

This causes the highlighting to happen quickly, meaning spawn positions 2 and 3 will become highlighted in quick succession instead of slowly, and I'm not quite sure how to change this.Excal2013-08-05 08:31:53
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Mon Aug 05, 2013 9:18 pm

Running out of ideas here. I've tried numerous things, and I'm not sure how to synchronize the two.

If anyone has ever done something like this (delayed object creation WITH highlighting of the object spawn area), please help.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234

Post » Mon Aug 05, 2013 11:19 pm

SOLVED!!



Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,234


Return to How do I....?

Who is online

Users browsing this forum: Bing [Bot], tdcostas and 27 guests