Jump to content

Create a rock column that emerges from the floor in a platformer


drhayes
 Share

Recommended Posts

I'm trying to make a rock column that grows out of the floor in a platformer game. After it grows, it'll look like this:

 

rock%20column.png

 

The columns can be pretty much any height. The sprite is split into two frames: the top (with the lighter color pixels) and the middle. I also want the column, while growing, to act as a platform for any sprites colliding with it so they can walk around on top of it. But I don't want it to be movable if something bumps into it.

 

The way I'm doing it now is I have a Group that has at least two sprites in it, one with frame 0 (the top) and the rest with frame 1 (the middle). This is going to work since the sprites have physics applied on them and immediately drop to the floor. If I set them immovable then they pass through each other (immovable don't collide with each other). If I don't, then the player can bump into them and send them skittering across the level.

 

My next thought was to create Images as I need to cover the height. I would then change the y position of the group while changing its mask to make it look like it's growing. But then there's nothing in the Group that has a body.

 

Can I give a Group a body? Is there some other approach I should take?

 

The other approach I thought about was manipulating the tilemap layer that handles my collisions to simulate the growing column. Not ideal, since it wouldn't lift any sprites already standing there and would probably make the tilemap do something disastrous like recalc all collisions while growing or something.

Link to comment
Share on other sites

Duh! I'm using a Sprite with no texture and adding the Images as children and this seems like a WAY better way to do it. Totally forgot that Sprites can have children.

 

I think this'll work. Might post more about updating the height and the mask and such.

Link to comment
Share on other sites

Okay, got it. I ended up not adding children since I couldn't crop them correctly. In my RockColumn's ctor I generate the column texture according to the height from the existing texture, then make a couple of tweens, one for the body height and one for the crop rect height. Add a debris emitter for effect and voila, a growing column.

Link to comment
Share on other sites

I didn't have a lot of luck giving a Group an arcade physics body; too many base properties weren't there. I spent some time wandering around in components-land based on how Sprite was set up, then decided I was ice-skating uphill and ripped it out.

 

Tilesprite, though... that's a good idea. I'll try that too since I need to learn how to use those to get my repeating tilemap backgrounds I think.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...