Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - superbany

Pages: [1]
help / Scrolling in Pause Menu
« on: Mon, Apr 16, 2012 »
I've been trying to get a working pause menu going for a while now. I started with the default, and have tried replacing bits of it at a time. However, I'm having trouble getting any buttons in the menu to scroll properly with the map, currently with only an unpause button. Here's the code:
Code: [Select]
public function PauseMenu()
scrollFactor.x = scrollFactor.y = 0;
var w:uint = 80;
var h:uint = 92;
x = (FlxG.width-w)/2;
y = (FlxG.height - h) / 2;

bgdSprite = new FlxSprite(0, 0, ImgBgd);
bgdSprite.alpha = .8;
add(bgdSprite, true);
add((new FlxText(0, 0, w, "PAUSED")).setFormat(null, 16, 0xffffff, "center"), true);

continueButton = new FlxButton(4, 31, unpause);
continueButton.loadGraphic(new FlxSprite(0, 0, ImgContinueButton), new FlxSprite(0, 0, ImgContinueButtonPressed));
add(continueButton, true);

add(new FlxSprite(4,50,ImgTestSprite), true);

The background, header text, and TestSprite all show properly, but the graphics for the Continue button do not scroll with the map. The button can be clicked where it should be at and works (currently only traces "unpausing..."), but the graphics are usually not visible, unless the player moves so the screen scrolls to the upper left corner of the map.
Any hints on how to get the graphics to scroll with everything else would be much appreciated. Thanks!

help / Overriding Pause
« on: Tue, Jul 12, 2011 »
I'm trying to override the default Flixel pause (with flixel v2.35), so I went and made my own PauseMenu class and set it up in my game.
The player can either press P to pause, or click a button on the screen to  call the togglePause() function in my game state. The button works fine, but for some reason, the P key has to be held down instead of pressed once to pause. Also, neither one show the test image I put in the pause menu, but it is shown when focus is lost in the main menu before playState is loaded. Any ideas?

Code: [Select]
public class PauseMenu extends FlxGroup

public function PauseMenu()
var testSprite:FlxSprite;
scrollFactor.x = scrollFactor.y = 0;
testSprite = new FlxSprite(64, 64);
testSprite.createGraphic(16, 16);
reset(0, 0);

override public function update():void
if (FlxG.keys.justPressed("P"))
FlxG.pause = !FlxG.pause;


Code: [Select]
override public function create():void
tempSprite = new FlxSprite(0, 0, ImgButtonPause);
_buttonPause = new FlxButton(FlxG.width - 10, FlxG.height - 9,togglePause);
_buttonPause.scrollFactor.x = _buttonPause.scrollFactor.y = 0;

override public function update():void
FlxG.log("1:" + FlxG.pause);
if (FlxG.keys.justPressed("P"))
FlxG.log("2:" + FlxG.pause);

protected function togglePause():void
FlxG.pause = !FlxG.pause;

For the log in playState's update, 1 is always returning false, and 2 is only true for a single frame once P is pressed.

Any help with what is happening here would be great. Thanks!

help / Non-colliding tiles
« on: Tue, Mar 29, 2011 »
For my platformer, I want to be able to make one-way platforms, using an embedded png and FlxTilemap for the locations of the platforms. I have a tileset made for the platforms graphics with collideBottom set to false, and with only the top three tiles drawn (both upper corners and the floor) to create the appearance of a small bridge.

You can see it here:
[Use WASD control, J to jump. Press B to see boundaries. Climb up to the right to see the brown platform above. Once on top, you can use the arrow keys to fall back through]

However, because I'm using FlxTilemap, the long horizontal platforms are split into two rows of blocks (only the top one drawn at all), each colliding with the player. This is not a problem most of the time, but jumping at exactly the right height can get the player to land in between the two rows, either causing them to appear to float in air or to warp up on top of the platform.

The best solution I can see would be to keep the player from colliding with this lower row of tiles, and only the higher one. I'm ok with the player warping up to on top of the platform a little bit, just not from this great of a distance.
Is there any way to change the <solid> variable to false for just these three lower tiles? And if not, are there any better ways to do what I'm trying here?

help / Mass sprite creation
« on: Thu, Feb 24, 2011 »
For my platformer game, I have 48x48 pixel animated water blocks that I want to spread around a level, but I don't want to have to revert to doing:
Code: [Select]
_water.add(new Water(x,y))over and over again.

I had made an auto tiler that fills the background with a repeating 64x64 graphic earlier, and I was trying to rework it to easily place water tiles in the right spots.
The original code was this:
Code: [Select]
var finishedBackground:Boolean = new Boolean(false);
var backgroundTileX:uint = new uint(0);
var backgroundTileY:uint = new uint(0);
while (!finishedBackground)
background.add(new FlxSprite(backgroundTileX, backgroundTileY, ImgBackground));

backgroundTileX += 64;
if (backgroundTileX > 980)
backgroundTileX = 0;
backgroundTileY += 64;
if (backgroundTileY > 1104)
finishedBackground = true;
which I reworked to make:
Code: [Select]
var finishedWater:Boolean = new Boolean(false);
var waterTileX:uint = new uint(0);
var waterTileY:uint = new uint(0);
var checkSpot:FlxSprite = new FlxSprite(0, 0);
var waterMap:FlxTilemap = new FlxTilemap() = FlxTilemap.ALT;
waterMap.loadMap(FlxTilemap.pngToCSV(ImgMapWater, false, 2), ImgWasteTiles);

while (!finishedWater)
checkSpot.x = waterTileX;
checkSpot.y = waterTileY;
FlxG.log("Creating at " + waterTileX + "," + waterTileY);
_water.add(new Water(waterTileX, waterTileY));

waterTileX += 48;
if (waterTileX > 980) //Max x value needed for area to be filled
waterTileX = 0; //Reset x value
waterTileY += 48; //Move y down 48px on the map
if (waterTileY > 1104) //Max y value needed for area to be filled
finishedWater = true;

The <waterMap> is from a .png for the level with blocks in the top left corners of where each water tile should be, using just some plain white <imgWasteTiles> so I can see that the map is being placed in the right spot. <checkSpot> moves across the map's x by 48 pixels at a time, then repeats over and over again at a 48 higher y value until it has reached the end of the map.

If I just leave out the check for if the blocks are in the right place and just have
Code: [Select]
_water.add(new Water(waterTileX, waterTileY));it all works fine, only there is water filling the entire area.

How can I get this to only place water in the spots needed?

Also, I'm not sure, but I think that since this is in the create() function of PlayState and not in update(), collision is not working, but that's just a thought. Thanks for any help anybody can give. Please let me know if you need any more info about part of this.

games / [WIP] Gridlocked
« on: Mon, Feb 21, 2011 »
I've posted some questions about it in the help section, and I thought I'd actually put info about my game in here.

This is my first project I've made in actionscript/Flixel. It's an action/adventure platformer built up from the FlxCollisions sourcecode, with kind of a Metroid type of gameplay. You can see it here:
Controls are:
WASD: move
J: jump
K: attack/interact
SHIFT: angle attack

You can throw knives to attack in all 8 directions by pressing either both two directions at once or by pressing shift to angle your throwing up/down. You can also wall jump by pressing against a wall and jumping.

There's still some stuff floating around for now (some water/acid, a test of a tilemap), but you can get the general idea of what it's going to look like.

help / Overriding in Groups
« on: Tue, Feb 15, 2011 »
For my platformer game, I've made my Player object extend FlxGroup, so that I can account for different parts of the body. The var _playerBody within that group handles all the physics, with _playerEyes following it.

What I'm wondering is: Is there any way to override functions for just one of the objects? I would normally put an override function at the end of my Player class, but that would affect the entire group, which doesn't actually collide with anything. I want to do things such as override hitBottom to reset the double jump counter, but only for _playerBody, since it is the only part that actually collides against the tilemap.

I could probably figure out a way to get the desired effect another way, but I just wanted to know if this is possible. Thanks.

help / Detailed water physics
« on: Tue, Jan 4, 2011 »
For my platformer, I'm making some areas that will be filled up with water, so I need some new physics for them. What I'm trying to get is the player to swim on top of the water until down is pressed, which then they will use underwater physics and the air meter will go down (Think of the 3d Mario games like Super Mario Sunshine). I've gotten it to work almost perfectly, except for a few bugs.

Current Code:
Code: [Select]
_water.add(new Water_top(144, 1938));
_water.add(new Water_top(96, 1938));
_water.add(new Water_top(48, 1938));
_water.add(new Water_top(0, 1938));
_water.add(new Water(144, 1984));
_water.add(new Water(96, 1984));
_water.add(new Water(48, 1984));
_water.add(new Water(0, 1984));


_curWater=PlayerGroup.inWater;  //Player's location in water previous frame.

_playerWater = 0;
FlxU.overlap(_playerBody, _water, waterOverlapped);

protected function waterOverlapped(PlayerObject:FlxObject, WaterObject:FlxObject):void
if (!_playerEyes.overlaps(WaterObject)) //Eyes are above water, meaning player can breathe.
if (FlxG.keys.pressed("S"))
_playerWater = 1;
_playerWater = -1;
else  //Player's eyes are below water level, but not necessarily because they are swimming underwater.
if (_curWater == -1) //If the player was supposed to be on top, sends them back upwards.
_playerBody.velocity.y = -10;
_playerWater = -1;
else  //Player can continue sinking.
_playerWater = 1;

For _playerWater and _curWater, -1 is floating on top of water, 0 is out of water, and 1 is underwater.

In the update(), a temporary variable _playerWater is assigned as 0, which is then changed depending on if the player overlaps the _water group, then both the health bar and player are told, so that they know whether or not the player should be losing air.

You can see it here:
The two problems are that:
1) This only works in the top half of the body of water, not the bottom (press B to see the divisions)
2) Crossing a vertical boundary between water tiles going left causes the player to think they should be floating on top.

Problem 1 should be able to be solved by replacing <!_playerEyes.overlaps(WaterObject)> with <!_playerEyes.overlaps(_water)> to check for the entire group, not just one sprite, but this does not ever return true.

I think Problem 2 is related to the order in which the water is added to the state, but I'm not sure.

If anybody has any ideas on how to fix this, that would be great. Please also ask if you need to see other code. Thanks for any help you can give.

help / Grouped Sprite [NOT solved]
« on: Mon, Dec 13, 2010 »
I tried this earlier and gave up on it, but I found that I'll have to do it anyways, and I might as well try to do it now.

I'm making a platformer, and I want the player to consist of multiple sprites, one for the body and one for the eyes, with different animations based on moving/aiming direction.

I previously had two objects added to PlayState, one <Player> and one <PlayerEyes>, both of which were sprites. PlayState in its update would use _playerEyes.setDirection(_player.knifeAngle) to determine what direction the eyes should face. And this has been working perfectly until now.

I decided that I should make it that the player cannot swim forever in water, and that they have to drown eventually. To do this, I needed an _air variable in _player, which would decrease when both _player and _playerEyes were overlapping water, but not if the eyes were above.

I could do it as it is, but I realized that it would be a whole lot more efficient to have one <PlayerGroup>, which contained two public sprites, playerBody and playerEyes. The PlayerGroup would have many miscellaneous variables, such as _canWallJump, _greenKeys, and _air.

Is there any way to easily convert my two sprites to one group?

-Also, I've tried making the group from the ground up, with the body being the only current member, but for some reason it is not colliding with the tilemap when I call FlxU.collide(PlayerGroup.playerBody, tiles) in PlayState's update. Any solutions?

help / Text boxes
« on: Fri, Nov 26, 2010 »
I am planning on making, for my platformer, signposts throughout early levels, so that the player can go up to them, press K, and a text box will pop up at the top of the screen saying things such as "press up to go in the next door" or "you need a key to open this gate". I want to create objects called MessageSpots, which I pass in their message string during their construction along with their X and Y values.

I just need help on how to make the message display as a flxText from within the object, but I don't know where to start. Any help would be great.

help / Sorting
« on: Tue, Nov 2, 2010 »
For my platformer, I'm trying to get the character's eyes to look in whatever direction the player is aiming. I create a <player> object in In, it creates an <_eyes> object, which is an instance of the PlayerEyes class, and adds it to the <_player> (different from <player>) group in PlayState. However, this puts the eyes behind the head, and they can't be seen. How would you do about reordering so that the eyes show up in front? Thanks.

help / Wall jumping
« on: Mon, Oct 4, 2010 »
I'm working on a platformer, and I'm trying to include wall jumping as a skill. To keep the player from bouncing straight up a wall, I make the character move away from the wall after every jump. However, this only seems to work when the wall is to the right of the player. Here's the code:
Code: [Select]
//[player coding]
else if (canWallJump)
if (FlxG.keys.justPressed("A"))
acceleration.y = 450;   //Resets gravity (lowered while sliding)
velocity.y = - acceleration.y * 0.5;  //Player jumps up
if (onLeftWall)  //Defined in the PlayState's update if colliding with the tiles on the left
velocity.x = maxVelocity.x;
if (onRightWall)
velocity.x = -maxVelocity.x;

I tried switching the order, but this only works on the right wall, and on the left wall the player  just goes straight up. Anybody see what's happening?

help / Group Overlap
« on: Sat, Oct 2, 2010 »
I'm currently working on a platformer game, and one of the things I wanted to do was to have some alternate player physics when underwater. I created my "player" object and placed some water objects into a group called _water with:
Code: [Select]
_water.add(new Water_top(16, 1978));I put this, along with some other groups for enemies, lava, the player, and doors into a meta group called _objects to use for collisions.
In the update method, I use
Code: [Select]
FlxU.collide(_objects, tiles);
FlxU.collide(_objects, _objects);
for the basic collisions.
However, when I tried to use
Code: [Select]
FlxU.overlap(player, _water, overlapped); with "overlapped" being a method to change the variable in the player called inWater to trigger water physics, nothing happens, and the water just acts as a background sprite. I checked, and it seems that the two aren't being recognized as overlapping. To try to figure out the problem, I replaced _water with the tiles variable, and the game was seeing that they overlapped. Anybody know what I'm doing wrong?

Looked through other forum posts and solved the problem. the Water_top objects needed to be solid, and just not included in with the other objects in collisions.

Pages: [1]