How would one go about repeating the collisions layer?
I'm still a beginner at some of this, It feels simple, but I just don't know how to go about doing it.
Thanks!
1 decade ago
by Arantor
I'm curious, why would you repeat the collision layer?
1 decade ago
by Joncom
I'm curious too.
You could try injecting some extra code into the collisionMap trace function:
// Repeating collision map (untested)
ig.CollisionMap.inject({
trace: function( x, y, vx, vy, objectWidth, objectHeight ) {
// Handle collisions right of the collision map.
if(x>this.width * tilesize) x = x % (this.width * tilesize);
// Handle collisions left of the collision map.
if(x<0) x = (this.width * tilesize) - (Math.abs(x) % (this.width * tilesize));
// Handle collisions below the collision map.
if(y>this.height * tilesize) y = y % (this.height * tilesize);
// Handle collisions above the collision map.
if(y<0) y = (this.height * tilesize) - (Math.abs(y) % (this.height * tilesize));
this.parent();
}
});
i want to repeat the collision too. i am just letting the player go x distance and then after x distance i am ending the level. the background and objects repeat and new enemies spawn in. my goal is to see who can go the farthest; think canabalt. that is why i want the collision layer to repeat. ill have to give this a try and see if it works because i really need to figure out a solution to this.
1 decade ago
by Arantor
If Canabalt is your goal, surely you need a long running - but ultimately variable collision map?
I'm thinking I'd do it with entities and reposition them as necessary.
i was thinking the same thing... but i think i am just going to check the bounds + the tile offset and lock the player from that area. that should work i believe.
Quote from Arantor
If Canabalt is your goal, surely you need a long running - but ultimately variable collision map?
I'm thinking I'd do it with entities and reposition them as necessary.
1 decade ago
by Joncom
In the event anyone reads this thread looking for a similar solution,
this is probably what you're looking for.
Joncom:
Thanks for the post, I was looking for exactly this for my title loading screen and you saved the day. Big ups to you.
Page 1 of 1
« first
« previous
next ›
last »