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.


Messages - superbany

Pages: [1] 2 3
1
help / Re: Scrolling in Pause Menu
« on: Tue, Apr 17, 2012 »
I'm actually using an older version of flixel (don't want to change midproject), so FlxGroup don't have a setAll to use.  :-\ But the button's scrollfactor is set to 0.

However, would it work to have, instead of:
Code: [Select]
continueButton.loadGraphic(new FlxSprite(0, 0, ImgContinueButton), new FlxSprite(0, 0, ImgContinueButtonPressed));to have:
Code: [Select]
continueButtonSprite=new FlxSprite(0,0,ImgContinueButton);
continueButtonPressedSprite=new FlxSprite(0,0,ImgContinueButtonPressed);
continueButton.loadGraphic(continueButtonSprite,continueButtonPressedSprite);

and then, whenever the game is paused, reset the locations of <continueButtonSprite> and <continueButtonPressedSprite> to match the screen location?



Oh, thanks. The art still isn't totally done yet.

2
help / Re: Scrolling in Pause Menu
« on: Mon, Apr 16, 2012 »
I want to have a simple pause menu, with buttons for volume control, returning to main menu, etc., not having the game continuing in the background.
Its just that the graphics for any buttons that I put in end up scrolling with the level and staying in the top left corner of the map, instead of remaining in fixed positions on the screen. So, pressing p to pause when the character is at the top of the map will cause the pause menu to work fine, but pausing anywhere else causes the image for the button to be displaced, or even off the screen, even though it is clickable at where it should be located.

Player located at top left of map:


Player moved right so the screen scrolls slightly over:

3
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()
{
super();
FlxG.mouse.show();
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!

4
help / Re: Overriding Pause
« on: Wed, Jul 13, 2011 »
I tried having only one before, and that caused problems too; removing the key command from playState pauses the game correctly when p is pressed, but then the game stays paused and the p key has to be held down to continue playing. Removing justPressed from the pause menu changes nothing.

5
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?

PauseMenu:
Code: [Select]
public class PauseMenu extends FlxGroup
{

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

override public function update():void
{
FlxG.log("inpause");
if (FlxG.keys.justPressed("P"))
FlxG.pause = !FlxG.pause;
super.update();
}

}

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

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

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!

6
help / Re: Collision problems
« on: Mon, Apr 18, 2011 »
When you press a button, is it directly changing the x value, or are you using velocity.x? If you are, that might be the problem.
Also, if collideLeft/collideRight is set to false, you'll also get the same result. Could you post the code you're using?

7
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:
http://www.newgrounds.com/dump/item/051720a5136a54a27e994162aba51217
[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?

8
help / Re: Mass sprite creation
« on: Sat, Mar 5, 2011 »
So I'm guessing for my <Water> class, I could add a <public static var frameNumber>, and have that update in <PlayState>, and have the water sprite only switch to that if its active.
I won't do that for now, since there's not much of a lag, but I might have to later when I add more objects. Thanks for the help, though.

9
help / Re: Mass sprite creation
« on: Sun, Feb 27, 2011 »
Well, I finally figured out what the problem was by editing the code so that I could reset the water animation whenever I wanted to.

I remembered that my water tiles have some extra coding so that, like the enemies, they deactivate their motion and collision when off screen.
I removed this part, and the animation is perfectly synchronized, but with all the water on the level constantly updating, its taking a bit of a toll on the framerate. Does anybody know any way to fix this?

10
help / Re: Mass sprite creation
« on: Fri, Feb 25, 2011 »
Wait a second...


FlxTilemap has a getTile() function?! O_o
AArgh!

That's kind of what I was trying to do, only I din't know Flixel had that function there.
Here's the new code:
Code: [Select]
var waterMap:FlxTilemap = new FlxTilemap()
waterMap.auto = FlxTilemap.ALT;
waterMap.loadMap(FlxTilemap.pngToCSV(ImgMapWater, false, 2), ImgWasteTiles);

for (var waterTiley:int = 0; waterTiley < tiles.heightInTiles; waterTiley+=2)
//+=2 because each waterMap tile is 2x2 tiles large
{
for (var waterTilex:int = 0; waterTilex < tiles.widthInTiles; waterTilex+=2)
{
if (waterMap.getTile(waterTilex, waterTiley) != 0)
//activates as long as tile is not blank
                {
_water.add(new Water(waterTilex * 8, waterTiley * 8));
}
}
}
(<tiles> is the main map tilemap)

I guess it would have been a whole lot easier if I had known about that function...
Anyways, you can see it here:
http://www.newgrounds.com/dump/item/051720a5136a54a27e994162aba51217
(thanks also for suggesting a nested <for>. It never crossed my mind as being an option)

So it looks like it works all well for adding main bodies of water. I can add more within the loop for other tiles such as the top of the water or acid to make one big multi-purpose tiler.

One problem I'm seeing though, (might be unrelated to this new method of coding used), but the water seems to be not entirely synchronized, with patches of blocks ahead of or behind others in their animation loop. See any way to fix this?

11
help / Re: Mass sprite creation
« on: Fri, Feb 25, 2011 »
Because I don't know exactly how to use DAME.
Also, the water tiles have their own coding for water physics depending on where the player is in it, and I'm not sure if dame will do that.

I just want to know if there's any easy way of editing my code to quickly create the blocks.

12
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()
waterMap.auto = FlxTilemap.ALT;
waterMap.loadMap(FlxTilemap.pngToCSV(ImgMapWater, false, 2), ImgWasteTiles);
add(waterMap);


while (!finishedWater)
{
checkSpot.x = waterTileX;
checkSpot.y = waterTileY;
if(checkSpot.collide(waterMap))
{
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.

13
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:
http://www.newgrounds.com/dump/item/051720a5136a54a27e994162aba51217
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.

14
help / Re: Overriding in Groups
« on: Wed, Feb 16, 2011 »
Oh, okay. Thanks.
I was hoping I wouldn't have to, but I guess I'll have to make a PlayerBody class for this. Thanks anyways.

15
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.

16
help / Re: Detailed water physics
« on: Tue, Jan 18, 2011 »
Well, I finally got it to work. I have to have a separate variable for the state called <highWaterY>, but that's not that big of a deal.

Here's the new code.
PlayState's update:
Code: [Select]
highWaterY = 9999;
_playerWater = 0;
FlxU.overlap(_playerBody, _water, waterOverlapped);
_hpBar.setWater(_playerWater);
_player.setWater(_playerWater);
PlayState's waterOverlapped function (with parameters PlayerObject and WaterObject):
Code: [Select]
if (WaterObject.y <= highWaterY)
{
WaterObject.flicker(.1);  //Just for debugging
highWaterY = WaterObject.y;

if (!_playerEyes.overlaps(WaterObject))
{
_playerWater = -1;
}
else
{
if (_curWater == -1)
{
_playerBody.velocity.y = -10;
_playerWater = -1;
}
else
_playerWater = 1;
}
}

if (FlxG.keys.pressed("S"))
_playerWater = 1;
And see it again here: http://www.newgrounds.com/dump/item/051720a5136a54a27e994162aba51217 (the flickering is just to show which water block the physics are being taken from)


What its doing is constantly resetting highWaterY to 9999 (or any really large number), then changing it whenever the overlapped water block's y is less than or equal to it. This is also the only time that the physics are redone, meaning the player will only be swimming in the higher up block(s). This way, the player will only float on the very top of the water, not in-between the sections.

I'll probably want to move the button control for sinking below the surface into the player's coding and make it not need to be held down, but that won't take much work. I'll also probably want to use the level height (about 2500) instead of 9999.
Unless anybody has any suggestions on how to improve this, problem solved.

17
help / Re: Detailed water physics
« on: Thu, Jan 13, 2011 »
What I'm thinking of doing is to have all that programming in WaterOverlapped only activate if the overlapped water object is the highest one in the group overlapping the player, so that if the player is between two, they will only overlap with the higher one, keeping them with underwater physics.

What I need to know though, is if I need to create a whole new variable for the state. Will I have to put a <protected var _highWaterY> and do the code only if WaterObject.y < _highWater (resetting _highWater to a really high value like 9999 every frame, and updating it if WaterObject.y is less than it), or can I just put a <var highWaterY> at the beginning of WaterOverlapped, since its overlapping with a single FlxGroup?

Or is there a better way to do what I'm trying to do? Thanks for any help.

18
help / Re: Detailed water physics
« on: Wed, Jan 5, 2011 »
Figured out how to fix problem 2. My custom command _player.resetEyes() [puts the eyes in the correct place relative to the body] was taking place after the overlaps, when it should have been placed after the tile collisions but before the overlaps. I also fixed it so that pressing S anytime sets the swim type to underwater.
See it again here: http://www.newgrounds.com/dump/item/051720a5136a54a27e994162aba51217

Newer code:
Code: [Select]
//UPDATE
_player.collide(tiles)
_player.resetEyes();
_playerWater = 0;
FlxU.overlap(_playerBody, _water, waterOverlapped);  //Skips if player is not in water at all
_hpBar.setWater(_playerWater);
_player.setWater(_playerWater);


//WATEROVERLAPPED
if (!_playerEyes.overlaps(WaterObject))
{
_playerWater = -1;
}
else
{
if (_curWater == -1)
{
_playerBody.velocity.y = -10;
_playerWater = -1;
}
else
_playerWater = 1;
}

if (FlxG.keys.pressed("S"))
_playerWater = 1;

I'm not really sure how to fix problem 1, but I don't think your suggestion will work. I'll try it out and see if it fixes it.

19
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]
//PLAYSTATE'S CREATE:
_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));

add(_water);


//PLAYSTATE'S UPDATE:
_curWater=PlayerGroup.inWater;  //Player's location in water previous frame.
super.update();

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


//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;
else
_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: http://www.newgrounds.com/dump/item/051720a5136a54a27e994162aba51217
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.

20
help / Re: Adding a little physics without Box2D
« on: Tue, Dec 21, 2010 »
I think that you could go with Yinan's idea.

For a box <_box> and another sprite <_thing>, you could use when colliding them:
Code: [Select]
if ((_box.x + _box.width/2) < (_thing.x))
     //rotate box counterclockwise.
else
     //rotate box clockwise.

The smaller the absolute value of (_box.x + _box.width/2)-_thing.x, the faster you would rotate _box. I'm not sure this would work, especially with a large sprite or a tilemap, but it should provide some framework to actually make it work.

Pages: [1] 2 3