1 decade ago
by gxxaxx
I found some great code for a camera plugin by Dominic in the forums.
http://impactjs.com/forums/help/screen-scrolling
I'm trying to implement that for my game.
The camera works great on the player. I have his update and the game update working well.
I was hoping to get a clue on what to do to make my enemies work again.
Those entities withing the camera view at level start work fine. But after I move to the side or up ( overhead type game) then the creatures don't work and my bullets won't spawn.
There must be some kind of adjustment required to make this function during spawnEntity and update that I am missing.
Any clues appreciated.
Thanks,
1 decade ago
by dominic
The screen position shouldn't interfere with Entity spawning and updating in any way.
Maybe you have some extra code in your entities that checks the screen position somehow? Or there&039;s just an error that's causing the Game's #update()
function to quit midway through? Are there any errors in your browser's console?
Can you show us the game?
1 decade ago
by gxxaxx
Thanks for the reply.
I can show a sample.
I just took another game I'm working on and made the screen size smaller so that a scroll would be implemented. Just trying to make sure the scrolling mechanism is working before I turn my friend (he designs the levels) loose on it.
I will post a copy of the game with the screen thing either tonight or tomorrow. Depends on how fast I can find a sfx that sounds like falling into a hole hehehe.
Sometimes the code drives me whacky and I have to switch out of coding mode and make a few entities to decorate the game. :)
Look forward to your feedback on the general direction.
1 decade ago
by gxxaxx
@dominic
I was preparing the sample for upload when I stumbled across the problem.
I was using code similar to
if (this.pos.x > ig.system.width) {
this.kill();
}
as a means to remove bullets and other projectiles that went off the map (through doors etc).
So I did a search and replace on all instances of system.width that were used on position comparisons and that fixed it.
I decided to use the collisionMap rather than backgroundMaps[0] cause my collision map is always the same size as my my playing layer. With scrolling backgrounds, I wasn't sure what the [0] map was.
this.mapwidth = this.collisionMap.width * this.collisionMap.tilesize;
this.mapheight = this.collisionMap.height * this.collisionMap.tilesize;
Now the camera works like a charm.
Just need to understand the camera parameters a little better so I can work out a non-flicker entrance into each succeeding level.
Page 1 of 1
« first
« previous
next ›
last »