Following a path?
-
Sorry but my brain is not firing on all cylinders today and I'm struggling to change the code from a single path (one shot fired) to multiple ones at the same time (several shots fired)
Here is the code for the single one and it works perfectly
This is my last effort at doing multiple ones via a loop
Which does not work at all, everything goes crazy.I'm obviously missing something here, if someone could give me a hint it would be great. thanks!
-
It is difficult to say without seeing more of the code and knowing what the intention was e.g what are the initial values of index and counter?
Just a minor observation but the array is called rpeats and not repeats is it?
-
Just make sure, that your values will take over into the next shot, when you set them, so for example stop will always be true once it was true for the first time in your loop
-
@SteveZX81 share your code Steve and I will take a look
-
@pianofire okay its shared (named chip) as the code stands it shoots single shots which work fine
dpad to change selection and press 'Y' to shoot.of course when there is one shot on the move and you press fire, that shot vanishes and your new one replaces it. that's why I wanted to add more (up to say 20)
There is no need to fix this but if you wish to look at the code as it is, its there.
-
@SteveZX81 Hi Steve, so I haven't got to the bottom of this yet but one observation is that in the traceshoot function you are only ever setting the location of the pshot sprite (not the ones stored in the shots array) so they will always be starting from -100, 0. I guess that you probably need a shot counter that gets passed into here?
-
in that version of the code yes. in all the attempts I've made to make multiple shots, I have changed all the pshot entries to shots[shotcnt]. but alas no joy.
don't worry about it, it was just a silly game idea anyway ;) -
how are you creating the shots array? and does it by anychance have createSprite() inside the array ?
-
@SteveZX81 Ok no problem. I think that the idea has potential. If I get some more time I might have another look.
-
@Martin The shots array is created like this (and yes)
shots = []
shotcnt = 0
for i = 0 to 20 loop
shots[i] = createsprite
..and then 3 lines for setting the sprite image, animation and scale followed by
repeatThe sprites do show up fine, but don't follow my traces (like the shared single trace code does)
-
OK, that's fine - there is a known issue (IMO) if the sprites had been created a different way so I just wanted to check. As you were...