Uhfgood Posted August 11, 2014 Share Posted August 11, 2014 Could anyone tell me if there's an easy way to do proper wraparound, where your sprite smoothly goes to the other side of the screen, where you can interact with it as if it's the original sprite like in asteroids? In general on old systems it had to do with writing to memory tha would write back to the other side, so it was sort of built in, however, we're not dealing with that in today's games, so instead we have to simulate it. The only way I know of is to have up to 3 other "clones" created, for each possible location. If you're on a corner you're going to be in 4 corners, hence 4 different sprites. Was hoping either phaser itself, or someone here would have a quick and easy way of accomplishing this? Note I have up to 60 asteroids on screen at once (generally this doesn't happen that often, but it would happen when you have the max of 15 asteroids on screen that get split into two smaller ones which makes it 30 and split into the smallest ones which would make it 60) -- so you're looking at potentially 240 asteroids on screen at once. Again I would stress that you normally wouldn't come close to this, it's just it could happen if you break up all 15 max asteroids into 60 and they all happens to go into the corners at the same time (highly unlikely, but is just a possibility). Any ideas? Link to comment Share on other sites More sharing options...
lewster32 Posted August 11, 2014 Share Posted August 11, 2014 Afraid if you want to actually have the sprite half way off one side and half way on the other side of the screen you're going to have to clone the sprite - that's just a limitation of the renderer unfortunately. If you were writing your own bitmap renderer for canvas or a RenderTexture you could reproduce the effect more authentically, but probably at the cost of a lot of performance, plus the collision code would no longer work. Phaser does have a World.wrap method which will take care of this kind of behaviour if you're prepared to have some padding where the sprite totally vanished off one side before reappearing on the other. Link to comment Share on other sites More sharing options...
Uhfgood Posted August 11, 2014 Author Share Posted August 11, 2014 Yeah that was one of the ways I was thinking about faking it, turn off collisions off screen, but have it completely vanish and then warp to the other side -- might have to go with that. -- It's not that likely that all 60 asteroids would be in the corners, so I guess that's a bit exaggerated Link to comment Share on other sites More sharing options...
Recommended Posts