1
\$\begingroup\$

just started using Phaser today after seeing Thomas Palef's lessmilk series. I completed PhotonStorm's "Make your first Phaser game" tutorial, and grabbed the skeleton, some CSS, and started to throw together a game. It's pretty barebones right now, but this is what I have.

The issue is that the game doesn't display the additional "orc" units I've requested. I used a for loop to throw five orcs around the map within the specified borders (32 pixels from the outside boundary. I even wrote a check for the x and y of each in the Update() function, but they don't appear at all.

I don't know how to move on from where I am, and I'm not sure that any of what I've written has been written the right way, you know what I'm saying? Thanks.

http://pastebin.com/if2VTq7j

\$\endgroup\$
  • \$\begingroup\$ OP here, I think it's worth noting that the score increases by 10 without my doing anything. Are the orcs spawning to the center of the map? \$\endgroup\$ – Spencer Jul 3 '14 at 4:31
  • \$\begingroup\$ You can edit your question if you have additional information. :^] \$\endgroup\$ – Heckel Jul 3 '14 at 6:19
  • \$\begingroup\$ Hadn't realized that my user was still unchanged, so I had assumed I was logged out. \$\endgroup\$ – Spencer Jul 3 '14 at 22:24
2
\$\begingroup\$

The issue is this part:

if (band.x > game.world.width - 64 || band.x < 64 || band.y > game.world.height - 64 || band.y < 64) { band.x = game.world.width / 2; band.y = game.world.height / 2; }

band is a Group. Groups are display objects in their own right, and their children (your orcs) are positioned relative to the x/y coordinates of the Group. Because your group starts out at x: 0, y: 0 it will fall foul of this check (band.x < 64) and be re-positioned to the middle of the game world, so all your orcs are now shifted off down to the bottom right of the screen and are forced "out of world".

I'm not sure what this part of your code is trying to actually achieve, but comment it out and you should at least see your orcs appear.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Holy crap, I don't even have know where this program is! Also, thanks for trying to help me out, because I was really, really lost trying to program that! You rock! \$\endgroup\$ – Spencer Oct 6 '16 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.