Tilemap Problem

72 views
Skip to first unread message

xhunterko

unread,
Sep 25, 2015, 8:21:27 PM9/25/15
to HaxeFlixel
I have a big problem. In my game, I have the enemies come at the player at the edge of the screen. This means they have to go under the tile map and can't collide with it. However, I still want them to collide with that same tile map. This has, for some reason, presented a huge problem for me. Here are a few things I've tried and thought of trying:

-Large invisible sprite object in the inner part of the tile map that the enemies hit, turning on a collide flag which then allows them to collide with the tile map. Causes slowdown.
-The outline of the large invisible sprite object in the inner part of the tile map. Causes slowdown.
-Secondary invisible tile map that the slimes collide with that switches on their collide flag. Causes slowdown.
-Idea: array of boxes in the outline of the large invisible sprite. But wouldn't that be a bunch of little boxes instead of one big one taking up the same space causing the same slowdown?
-Idea 2: Using lighting segment feature as fence that the slimes hit, causing a colliding flag trigger. But, again, wouldn't it be just a thin array of small boxes taking up the same amount of slowdown as the large object?
-Idea 3: Using createLine to make a fence that the slimes collide with using pixelPerfect. But, since that line is created out of a large object, wouldn't it again, cause the same large slowdown?
-Idea 4: Using the lighting feature itself by putting several lights of various size in the inner part of the tile map the slimes can hit that would then trigger their collide flag. But, wouldn't the lights themselves cause slowdown as well?

I have no idea. So, my final thought process was this:

Some how, get tell the slimes that they are in the inner part of the tile map.

Which led to the question and problem I have.

How can I check (within the PlayState state itself) if an object part of a group is within a non-colliding tile so I can switch it's colliding flag trigger so it will collide with the colliding tiles of the tile map?

Or, how can I check if an object in a group is in a blank or non-colliding tile map tile?

SruloArt

unread,
Sep 26, 2015, 3:14:06 PM9/26/15
to HaxeFlixel
* Just don't make your enemies spawn outside of the map. It doesn't really make much sense in the game world, unless they are subterranean, but even then. This is normally solved by placing a spawner within the map, like you can see in mode.

* Another option: Make (tile) doors. Maybe the player is opening a door to a room and a flood of monsters is coming out and he must close the door while he pushes against the monsters or whatever.

* And you can always carry-on with your plan if you remember that cloud tiles aren't just for jumping below platforms. 

xhunterko

unread,
Sep 28, 2015, 3:00:56 AM9/28/15
to HaxeFlixel
I've been able to get this working with no black screens:

for (gel in enemyGroup)
       
{            
           
           
           
if (gel.overlapsPoint(collidePositions)) {
               
                gel
.collidesMap = true;
               
FlxG.sound.play("Splat", 0.55);
           
}
           
           
           
if (gel.x == collidePositions.x) gel.collidesMap = true;
           
if (gel.y == collidePositions.y) gel.collidesMap = true;
           
       
}

However, no sound is playing. Which means the flag isn't being set true either. It seems like this is getting close to something and should work.
What am I doing wrong here?

I want the enemy to know if it's within an empty tile and switch a flag so it can collide with the tile map. Am I heading in the right direction here?
Reply all
Reply to author
Forward
0 new messages