GourmetGorilla Posted May 8, 2015 Share Posted May 8, 2015 My group aliens is moving around. At some point I remove a single alien and put it in a deadAlien group like this:deadAlien.add(alien);However, my deadAlien group does not have the same x, y as the 'alive' aliens group. they just move to the top of the canvas. Ok thats's easy to fix right? deadAlien.x = aliens.x; deadAlien.y = aliens.y;However, now my deadAliens constantly move around in sync with the alive aliens. Once an alien dies and is moved from the Aliens group into the deadAliens group, I need it to not change position (not to move to the top of the canvas), but also not have it's position dictated over time by the aliens group.How do I accomplish this? Link to comment Share on other sites More sharing options...
GourmetGorilla Posted May 8, 2015 Author Share Posted May 8, 2015 OK I tried the following: var deadAlien = alien; deadAlien.x = alien.x; deadAlien.y = alien.y; deadAliens.add(deadAlien);It's solved my scoring problem, as the scoring relies on living aliens, and when they're now in the deadAliens group, they're counted as dead. However, the deadAliens are not taking on the x, y position of the alien just as he was shot, the deadAlien is still jumping to the top of the page How do I stop them moving up there? Link to comment Share on other sites More sharing options...
GourmetGorilla Posted May 8, 2015 Author Share Posted May 8, 2015 Ok I fixed it. Sprite.world.x get's the global canvas coordinates of the sprite.var coord1 = alien.world.x ;var coord2 = alien.world.y ;var deadAlien = alien; deadAlien.x = coord1; deadAlien.y = coord2; Link to comment Share on other sites More sharing options...
Recommended Posts