Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Why won't my for loop sprites work?

Author
Message
Purplepickle
13
Years of Service
User Offline
Joined: 4th Jun 2011
Location: Between hopeless and needs improvement..
Posted: 3rd Sep 2011 03:13
I'm lost with my for statement...



Wait, what?
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 3rd Sep 2011 03:22
I think because you are declaring x and y the same thing for each sprite, so nothing will happen.
Purplepickle
13
Years of Service
User Offline
Joined: 4th Jun 2011
Location: Between hopeless and needs improvement..
Posted: 3rd Sep 2011 03:56
I knew that they were the same but didn't know how to fix it?

Wait, what?
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 3rd Sep 2011 23:29
Hi Purplepickle, I'm going to guess that you haven't figured this out yet.

The variable you need use to control the player need to be different to the variables used to control the enemie, as implied by Mr Bigglesworth. You could give them completely seperate variable names or you can use a arrays, which are then used in conjunction with the FOR TO NEXT loop to control all the sprites.

The example below gives you an idea of one of doing this. Use the arrow keys to move the green box and a circle will be drawn around it if it hits one the red boxes.



Hope this helps.

Login to post a reply

Server time is: 2024-11-22 17:14:16
Your offset time is: 2024-11-22 17:14:16