Enemies horizontal and vertical random movement

Get help using Construct 2

Post » Wed Sep 10, 2014 4:58 pm

@codah looks to have a solution there.

I would also agree that a single sprite would be better here. Then you could just make 4 animations based on the 4 directions. Once a direction is chosen, you can then use the Set Animation action to change what direction animation is playing.

Also for smaller lists, an easier expression for random lists of things is the choose() function:

i.e.: choose(1,2,3,4) - for direction
OR
choose ("SWalkUp","SWalkDown","SWalkLeft","SWalkRight") - For random animation (but keep in mind you have to then move in the correct direction as well)
B
33
S
10
G
4
Posts: 50
Reputation: 3,497

Post » Thu Sep 11, 2014 4:12 am

@codah thanks a lot for your help and your time. I tried implementing what you did and fixed but I seem to be having a conflict of instances. I can't pinpoint the bug. Do you know what it might be? :oops:

https://www.dropbox.com/s/w1dlofmnbj3v5 ... .capx?dl=0
B
5
S
1
Posts: 38
Reputation: 482

Post » Thu Sep 11, 2014 5:54 am

jminfantem wrote:@codah thanks a lot for your help and your time. I tried implementing what you did and fixed but I seem to be having a conflict of instances. I can't pinpoint the bug. Do you know what it might be? :oops:

https://www.dropbox.com/s/w1dlofmnbj3v5 ... .capx?dl=0


By the way I was not saying my capx contained best practices.. I would not really suggest all that visible/invisible stuff, especially if you had to repeat it lots of times..

Edit: ok so you have an object called 'Sprite' that is not placed on any layout (C2 needs this). However Sprite is not being used so just remove it.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Thu Sep 11, 2014 2:30 pm

@codah Thanks a lot for your help. I was able to figure it out.

I know it might not be the best practice especially if the game will have around 10 enemies. But I will use it until I can device a simpler solution.

Again, thanks a lot for your time. :)
B
5
S
1
Posts: 38
Reputation: 482

Post » Thu Sep 11, 2014 9:28 pm

jminfantem wrote:@codah Thanks a lot for your help. I was able to figure it out.

I know it might not be the best practice especially if the game will have around 10 enemies. But I will use it until I can device a simpler solution.

Again, thanks a lot for your time. :)


Very true, sometimes good enough is best :)
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests