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 - nitram_cero (2bam)

Pages: [1] 2 3
1
games / Survive Quest released!
« on: Sun, Jul 14, 2013 »
It's a short adventure game, homage to the hardness of Sierra's classics like Space Quest, King's Quest, Leisure suit Larry, etc. from the CGA era.
In english and spanish.

Made using Flixel 2.34, Graphics Gale, a Kaossilator 1, SFXR and Audacity.

Click here to play
http://2bam.com/play/SurviveQuest


2
I'm working on a project (w/deadline) using Flixel v2.34 and can't afford migration to the new code. Just posting this for any of you in the same situation.

The bug goes like this: If the tilemap is not at (0,0) position, any object colliding with the rectangle hull of the tilemap will weird up (In my case, it was pushing back an object where it was clear that the tilemap was empty).

preCollide() set's incorrectly the colOffsets for FlxU.solveXCollision() to work with.

To solve the issue, change this line at FlxTilemap.preCollide():
Code: [Select]
colOffsets[col++] = new FlxPoint(x+c*_tileWidth, y+r*_tileHeight);
For this one (removes x and y)
Code: [Select]
colOffsets[col++] = new FlxPoint(c*_tileWidth, r*_tileHeight);

Regards
-Martín

3
This fix is for 2.35, but I've checked github and seems that Flixel still uses the same code.

If you change these lines @ FlxSprite.getScreenXY():
Point.x = FlxU.floor(x + FlxU.roundingError)+FlxU.floor(FlxG.scroll.x*scrollFactor.x) - offset.x;
Point.y = FlxU.floor(y + FlxU.roundingError)+FlxU.floor(FlxG.scroll.y*scrollFactor.y) - offset.y;


For these new ones:
Point.x = FlxU.floor(x + FlxU.roundingError + FlxG.scroll.x*scrollFactor.x) - offset.x;
Point.y = FlxU.floor(y + FlxU.roundingError + FlxG.scroll.y*scrollFactor.y) - offset.y;

Overall it looks less jittery.
I tend to use FlxG.scroll directly (no FlxG.follow()) and in some specific positions the followed entity was jittering back and forth all the time.

Your milage may vary. I hope it helps!

Regards

4
releases / Is Flixel being maintained?
« on: Thu, Jul 29, 2010 »
Sorry, I haven't been around the forums for a while (work, work, work).
But from time to time when I find a bug in Flixel (as I work with it) I post it on the github issue tracker system. Usually with a solution.

But months go by and I read no replies.

Here are some:

Critical bug (w/fix) - createBitmap "unique" parameter is not respected, making FlxFlash work incorrectly.



Critical bug (w/fix)- calcFrame raises an exception if there is an animation callback but not an animation being played



Bug (w/fix) - FlxObject.overlaps() incorrectly checks against FlxSprite's image-frame width/height instead of the object's real collision box (offset/width/height)


Request - preCollide to return a boolean to avoid checking collisions altogether between objects given certain conditions.

Maybe Adam is too busy to do it himself, and thats cool, but I think this project has a lot of users and maintenance should be delegated in order to make these updates more frequent.

Thanks for the read.

-Martín

5
help / Selective collisions, a solution.
« on: Fri, Jul 2, 2010 »
Hi guys, It's been a while  ;D

I've been working a lot so I hand't got much time to (ever again) release Flan or post on these forums. And the question I'm asking is also for work...


I remember in Flixel 1.x that you could "return false" on a collision routine override to avoid the collision ever happening (back in the day when they had no parameters and returned a boolean, and "hitBottom" was called "hitFloor"..etc)

I can't find a way to do that now. I avoid calling the "super.hitWhatever()" but that doesn't seem to work.
I want to selectively collide (or not) different kinds of objects depending on their state, and making FlxGroups for each is prohibitively slow.

Any ideas?
Thanks :)
-Martín

6
help / Double-click help.
« on: Wed, May 12, 2010 »
I'm trying this but it doesn't seem to work:

Code: [Select]
private function handleMouseDblClick(event:MouseEvent):void
{
trace("DblClick");
}

override public function destroy():void {
super.destroy();
FlxG.stage.removeEventListener(MouseEvent.DOUBLE_CLICK, handleMouseDblClick);
}

override public function create():void
{
super.create();
FlxG.stage.doubleClickEnabled = true;
FlxG.stage.addEventListener(MouseEvent.DOUBLE_CLICK, handleMouseDblClick);
}

If anyone succeeded in doing so, I'll appreciate your help.
I'm trying to avoid nasty Flixel hacks (timing clicks and such); I wanted to go with the Flex way of doing it just to avoid having to merge a customized version with the next flixel releases.

Thanks and best regards!

-Martín

7
I found out about this today and might be good-to-know for any fellow flixelers

Symptoms:
-Preloader never shown
-Flx.debug always false

These lines are usually seen in the main class derived from FlxGame (the one always-compiled)
Code: [Select]
[SWF(width="800", height="600", backgroundColor="#000000")]
[Frame(factoryClass="Preloader")]

They should be placed after all imports (e.g. "import org.flixel.*"), otherwise they will be discarded without any notice.

The game might apparently work ok, but the preloader is never called, and, for instance, FlxG.debug will never be set correctly.

I'm using FlashDevelop with Flex 3.4

Cheers

8
games / Space Coffee
« on: Fri, Feb 5, 2010 »
Space Coffee

Quick little shmup made in under 4 days as a birthday gift.
Please don't be picky. The bad english is intentional.
4 minutes of gameplay.


Play online

Regards  ;D

9
help / Kongregate statistic calls frequency
« on: Thu, Feb 4, 2010 »
Hi there, I'm trying to integrate to the Kongregate API.

Does anybody know if I can call it all the time (imagine a Shmup score changing by second), or should I send it at the end of the level?

Perhaps the API does some caching or something before sending the value, that's why I'm asking if I should take care of it myself or just toss it to the API.

Thanks in advance
Regards
-Martín

10
I'm doing some tests on Whacky Whacky (for Flan export) and found out that, differently from the 1.25, the 1.54 weirds up heavily when changing width/height of an object.

Previous behaviour (1.25): http://www.tbam.com.ar/play--whacky-whacky.php
New behaviour (1.54): http://www.swfcabin.com/open/1264609275

What's going on?  :o
Hehehe

EDIT: This is the snippet:
Code: [Select]
protected function adjustPlayerSize():void
{
_player.offset.x=Math.floor(16*-(_player.scale.x - 1)/2);
_player.offset.y=Math.floor(16*-(_player.scale.y - 1)/2);

_player.width=16*(_player.scale.x);
_player.height=16*(_player.scale.y);
}

Code: [Select]
_player.scale.x+=0.15;
_player.scale.y+=0.05;
adjustPlayerSize();

Regards

11
I found a problem in the collision code:

Let's say...
lyrMain is a layer that contains ONE tilemap.
lyrPlayer is a layer that contains ONE player sprite.

Code: [Select]
FlxG.collideArrays(lyrMain.children(), lyrPlayer.children());Works as expected, the the player collides just the collidable tiles inside the tilemap.

Code: [Select]
FlxG.collideArrays(lyrPlayer.children(), lyrMain.children());This fails, the tilemap is collided as if it were just a core (one big rectangle), not working as expected.

This is pretty ill-defined, and regardless of any documentation that could explain it... it's hard to find and fix. I suggest that both work the same way to make it more intuitive on the library user.

Regards

EDIT: Woops, sorry about posting here :-[

12
help / FLAN SUPPORTERS: Mails marked as spam.
« on: Fri, Jan 8, 2010 »
Hi there Flan supporters!

To each one of you 10 people that were the coolest guys on earth to buy a Flan license, I've personally wrote a thanks message and attached your License PDF, via e-mail.

It came to my attention that those mails were marked as SPAM, and perhaps some of you didn't receive it.
I'm making this announcement because I don't want to end up looking rude. :-[

If you didn't get your license PDF, send me a mail and I'll send it again.

Best regards and happy game makin'
-Martín

13
Either if you hate banners or if you have your own, with this little script you can avoid that.

Put this code before the between the <body> </body> tags.
Code: [Select]
.
.
.
<script type="text/javascript">
<!--
if (top.location != self.location) top.location = self.location;
// -->
</script>
</body>

Some sites, to work around site-locking, just show your game in a frame, while putting their ads on top.
I've found that my ad clicking rates dropped significantly when a site did this.

It's a simple easy solution

Enjoy :)

14
If you're using swfobject like myself, do like this:

Quote
...
<head>

   <script src="js/swfobject.js" type="text/javascript"></script>
   <script type="text/javascript">
      var flashvars = {
      };
      var params = {
         menu: "false",
         scale: "noScale",
         allowFullscreen: "true",
         allowScriptAccess: "always",
         bgcolor: "#000000"
      };
      var attributes = {
         id:"flashObject"
      };
      swfobject.embedSWF("flashgame.swf", "flashAltContent", "800", "600", "10.0.0", "expressInstall.swf", flashvars, params, attributes);
   </script>

</head>
<body bgcolor="#000000" onLoad="document.getElementById('flashObject').focus();">

...

If you're using the straight dope, do like this:
Quote
<body bgcolor="#000000" onLoad="document.getElementById('flashObject').focus();">
...
<object id="flashObject" width="800" height="600" type="application/x-shockwave-flash" data="flashgame.swf">

And you can start playing right away, without having to click on the game to start.

Regards!

15
games / Finding Her (Flash) -- LD16 entry
« on: Sun, Dec 13, 2009 »
Flixel fellowship... I present my LD16 entry.
It's been made with Flixel v1.25 + B-Flixel.

Hope you like it.
-Martín




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You wake up dreaming of her...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

While exploring the cavern searching for this girl
 you start exploring deeper into the inhabitant's lives,
 asking questions that will help you find her.

Can you do it?

(This is my LudumDare 16 entry)

Click here to play (Flash)

Click here to see the video

Click here to rate it (LD)


Best regards
-Martín

16
Hi, I found that these lines are incorrect (@ FlxTilemap.as):

Code: [Select]
for(var r:uint = 0; r < ih; r++)
{
if((r < 0) || (r >= heightInTiles)) continue;
for(c = 0; c < iw; c++)
{
if((c < 0) || (c >= widthInTiles)) continue;

Because r and c are offsets. The real check should be made like this to avoid overlaps (If you have differently sized layers and collide to both, it could lead to some strange blocking in plain "empty" cells.

The Fix
Code: [Select]
for(var r:uint = 0; r < ih; r++)
{
if((r+iy < 0) || (r+iy >= heightInTiles)) continue;
for(c = 0; c < iw; c++)
{
if((c+ix < 0) || (c+ix >= widthInTiles)) continue;

Regards


17
       Sal & Caramelle in       
 Saving Professor Caffèlatte  
                                           


I'm working on this little puzzle game. It's about a hard candy and a smoked salt canister trying to save their friend, the professor.
The gameplay resembles the lost vikings style, characters depend on each other's abilities to overcome obstacles.

Caramelle: Fast and little, he can get through small gaps and jump.
Salahumad: He's the strong, indestructible and... dumb character. He can't jump or move fast but blasts his hat with great power and endures almost anything.

I hope it to be fun to play, but it's not the work of my life :)

It's still in it's diapers but, as always, any comments are welcome.

Best regards
-Martín

18
releases / v1.25 - Flickering could last forever [Fix]
« on: Sun, Oct 18, 2009 »
In some strange situations, flickering can keep forever. It happened to me with flicker(0.25);

Why?

See the code @ FlxCore.as (I dunno if it's exactly as the v1.25 version)
Code: [Select]
virtual public function update():void
{
if(flickering())
{
if(_flickerTimer > 0)
_flickerTimer -= FlxG.elapsed;

if(_flickerTimer < 0)
flicker(-1);
else
{

Specifically this:
Code: [Select]
if(_flickerTimer > 0)
_flickerTimer -= FlxG.elapsed;
_flickerTimer could end up being EXACLTY 0 (Although it's not likely, it happened to me a lot when _flickerTimer was 0.25, dunno why)
And EXACTLY 0 means "flicker forever".

You should change it for this...
Code: [Select]
virtual public function update():void
{
if(flickering())
{
if(_flickerTimer > 0) {
_flickerTimer -= FlxG.elapsed;
//sometimes you can just hit 0, leading to a bug. It happened to me with flicker(0.25)
if(_flickerTimer == 0)
_flickerTimer = -1;
}

if(_flickerTimer < 0)
flicker(-1);
else
{

Regards!

19


I collide it against a tilemap but can't get inside some gaps:
It can walk ok in the gap below, but when I try to jump into the higher gaps, I have to be ninja-precise to enter.
The tiles are 16x16. My character is 16x15 pixels. I even tried 16x12 but it's the same deal.

I can't use a broader gap because I need 1 tile gaps for the puzzle logic of my game.
Did anyone found the same problem and hopefully a solution?

Thanks!
-Martín

20
help / B-FLIXEL: A Flixel branch [ v1.25-C ]
« on: Wed, Sep 23, 2009 »
B-FLIXEL
A Flixel Branch [ v1.25-C ]


Documentation Wiki (If it's not there read the CHANGELOG.txt or investigate the .as files).

Download links are also there. Just check if they're from 2bam.com or tbam.com.ar.



In accordance with Adam, I'm posting my extension to flixel.
It's a modified version of flixel and has some useful extra stuff.

The idea is to have more frequent (xD) updates, maybe more hackish or with temporary workarounds;
Keeping vanilla flixel pure and easy, while still having a place to go for if you need a quick fix or a bit more advanced stuff.

It should work seamlessly with your game if it uses the unmodified flixel (except for the space key, read below)



================================================================================================
B-FLIXEL: A Flixel branch - v1.25-B
================================================================================================

--- Added 2 fonts ---
Added 2 free-license fonts I fancy: small (5px font) and blobby (reminds me of bubble bobble).

--- Wordwrapping in FlxText ---
FlxText.wordWrap [Boolean]
BlxInputText.multiline removed. Use FlxInputText.wordWrap instead (inherited from FlxText)

--- Avoding multi-handling of the same mouse click ---
FlxG.wasClickHandled()   Returns if a mouse click was already handled.
         Implemented in FlxButton. Avoids double clicks on buttons.
FlxG.handleClick()   Allows you to mark the click as handled and avoid buttons being pressed.

--- Alpha on FlxText/FlxButton ---
Community user mklee's alpha for FlxText & FlxButton.

--- Save data locally ---
Community user Merve's "FlxG.saved" shared object to save data locally
Usage (strict mode):
Save:
   FlxG.saved["highscore"] = highscore;
   FlxG.saved.flush();
Load:
   highscore = FlxG.saved["highscore"];

--- Kongregate API ---

Included AdamAtomic's FlxKong


--- FlxFactory better site-locking ---
More secure site-locking
Instead of just checking if it contains a string, it's checked from the beginning.
Of course it remains backward compatible if you don't set the sitelockURLs variable.

protected var sitelockURLs:Array;
   You assign this array on your preloader.
   You add stuff like "yoursite.com" and then is prefixed with "http://" and "https://" in combination with "www." prefix and just plain link.
   i.e. ["mysite.com"] will check against:
   http://mysite.com
   http://www.mysite.com
   https://mysite.com
   https://www.mysite.com

protected var playableFromHarddisk:Boolean = true;
   Adds ["file://", "http://localhost", "https://localhost" ] to the sitelocked list. It's the best for debugging (also "release testing") sitelocked versions on your own pc.
   Perhaps someone wants to disable this to avoid players downloading the game and forcing them back to their portal?...

protected var myLinkURL:String;
   this is the link showed in the sitelock screen (instead of using myURL)
   Two reasons
   1. If someone steals your flash game, you might want to point to your own site instead of the portal.
   2. If you are using sitelockURLs, well, you have to choose a link to show anyway.
   By default is equal to myURL if not set, or to sitelockURLs[0] if it's not empty.


================================================================================================
B-FLIXEL: A Flixel branch - v1.25-A
================================================================================================
Synopsis of B-Flixel elements
================================================================================================
(The reasons and specifics for all these are below...)

Debugging utilities: _DEBUG, ASSERT()
Button that work with links
Sub states + manager
Flags for internal functionality
Input text field
Custom logo on loading screen
"MochiPreloader" already setup to work with MochiAds


FlxArray: update/render/remove/cleanupNonexistent

FlxButton: setText(), fix for scroll factors != 1, no triggering if hovering while mouse button pressed.
FlxCore: keep track of owner layer, blinking ("slow flickering") and patched with AdamAtomic's speed fix
FlxG: open URL in new window, game background color, save data across levels with custom "*" reference.
FlxLayer's internal FlxArray made public
FlxSprite: find/remove animations. Fixed randomFrame()/specificFrame() to work with facing
Hack for FlxText  that tries to remove blurring
Dynamic FlxTilemap: changable during gameplay, overlap()/overlapArrays(), export as CSV, create empty if no CSV.
Z key also triggers "B button".
Space has it's own FlxG.kSpace/FlxG.SPACE. No longer SPACE/TAB/ESC bindings nor fullscreen mode.
FlxG.log saves data if no console present, then shows it (after FlxGame was setup, i.e. super() called)


================================================================================================
New classes and stuff in B-Flixel v1.25-A
================================================================================================

_DEBUG
   Global _DEBUG variable to know if the game was compiled in debug or release mode.

ASSERT(Cond, Msg=null)
   Global function to add pre- and post-condition checks to your code in debug mode.

MochiPreloader
   Ready to set up mochi preloader.
   You must change a line in your compiled ".as"
   from
   [Frame(factoryClass="Preloader")]
   to
   [Frame(factoryClass="MochiPreloader")]

com.tbam.bflixel.BlxURLButton
   Gets around popup-blockers by adding handling mouse events directly.
   Works with cascaded-layers seamlessly.
   Construct it as a regular FlxButton and call FlxG.openURL without worries.

com.tbam.bflixel.BlxSubState

com.tbam.bflixel.BlxG
   A sort of grabbag for any left over functionality (like FlxG, you know...)

   Functions:
   .randomInt(A, B): returns a random integer number between A and B (inclusive)
   .randomNum(A, B): returns a random decimal number between A and B (exclusive, but really near)

   User changeable constants:
   .IF_MULTIPLE_LAYER_ADDITIONS = DO_NOTHING or ADD_TRACE or RAISE_DEBUG_ERROR (default)
      Adds a check to FlxLayer.add code to avoid double core inclusions (that will call double updates/renders)
   .ENABLE_TEXT_ANTI_BLUR_HACK = true(default) | false
      Enable/disable anti blur hack
   .ENABLE_LOST_FOCUS_PAUSE = true(default) | false
      Enable/disable pausing if the game loses focus
   .STAGE_FRAMERATE = 90 (default)
      If you're gonna disable pausing I suggest you tweak this value so the player
      can do other stuff in their computer besides leaving the game on.
      I found Caverns to work better on 60FPS
   .SHOW_INPUT_HELP_ON_PAUSE = true
      If you're using your own input system, you better disable the A/B/mouse/arrows help on the pause
      menu. This flag facilitates that.

com.tbam.bflixel.BlxTextInput
   A text input field that goes with the flixel workflow (layer-cascade friendly)
   You can filter keys (Alpha/Number/Custom...), set it multiline, as password field,
   max length, uppercase forcing (e.g. for submitting only 3 uppercase initials for a hiscore),
   readonly (but selectable-copyable), background color, border, etc.
   More info on the .as file itself.

com.tbam.bflixel.BlxSubState
   SubState, for example for an inventory window or a (non-standard) paused screen
   You can override update and render for customized behaviour.
   This actually derives from a FlxLayer, so you can ".add()" stuff to it to show when enabled
   .enable()/disable():   Enables/disables it (shows/hides it)
   .toggle():      Toggles between enabled and disabled states
   See below everything for a usage example.

com.tbam.bflixel.BlxSubStateManager
   You .add() BlxSubStates to this (first one added has highest priority)
   See below everything for a usage example.

================================================================================================
Differences between Flixel 1.25 (vanilla) and B-flixel v1.25-A
================================================================================================

@ FlxFactory:
Custom logo for loading screen (you _need_ to put a "loading_logo.png" in your src folder). It will show up on top of the loading bar
Some stuff to make it work with MochiAds

@ FlxArray
.cleanNonexistent(): Removes non existing cores from the array (i.e. if core.exists == false)
.update():   FlxLayer's update functionality has been put in FlxArray, for convenience (if you update some cores manually)
.render():   FlxLayer's render functionality has been put in FlxArray, for convenience (if you render some cores manually)
.remove(core):   Call this to remove

@FlxButton
.setText(textBoth):      Sets the button's text
.setText(textOff, textOn):   Sets the button's on and off texts separatly
FIX: If sweeping the cursor over the FlxButton while the mouse button was down no longer triggers it.
FIX: It works correctly with scrolled states (if it's scrollfactor != (1;1))

@FlxCore
.ownerLayer [FlxLayer]: If it was added with FlxLayer.add(), it holds the last layer to which the core was added to
         Usually it should be only one (for render/update purposes)
         If removed with the new FlxLayer.remove() function, this gets reset to null.


.blink(Duration, BlinkPeriod):
         This avoids the ultra-fast flickering when you call flicker().
         (If you ask me it looks much better for a character "invulnerable" state)
         This is "built on top of flicker", so you can't be flickering and blinking at the same time.
.blinking()   Same as flickering(), to know if the core is blinking

FIX: It has been patched with AdamAtomic's speed fix (see the official Flixel help thread)

@FlxG
.openURL(URL, newWindow=true): Now openURL allows you to select if it opens a new window or not.
      Thanks to BlxURLButton the NEW DEFAULT mode is set to true (to avoid quitting the game).
.bgColor [uint]: Set the game's background color
.levelData [ * ]: You can assign anything you want to this variable (like an object with properties)
.log() now works regardless of the gamestate (it saves the log messages if no console is present)
   BUT it must be called after FlxGame's derived class "super()" call
   Also traces() whatever it's passed
   I had to do it due to a failure of trace capturing on the first moments of the app run
.kSpace/.SPACE
   Instead of binding

@FlxGame
now the "Z" key is also binded to FlxG.kB/B, to allow the "flipped" configuration
   (for people used to jump/fire the other way, can use ZX instead of XC)
SPACE and TAB are no longer binded to button A/B
SPACE is now binded to FlxG.kSpace / FlxG.SPACE
There is no more experimental fullscreen mode on ESC.

FALTAN RETOQUES!

@FlxLayer
.children (FlxArray): "_children" replaced by "children" and made public. Useful for collide and overlap functions (to avoid separate array/layer)
.update()/render(): Now calls children.update()/render().

@FlxSprite
findAnimation(name):   Find an internal animation, in case you want to change it's framerate or something (For different speeds)
         (Just in case: I recommend you cache it instead of calling findAnimation all the time)
removeAnimation(name):   In case you want to CHANGE an animation, you need to remove it first (useful for extending classes, like special enemies with a changed behaviour)
FIX: randomFrame/specificFrame() now can work with "facing" (before it returned to frame 0 always). Useful for random debris objects that can change direction if held (like Spelunky's debris)

@FlxState
_layer (FlxLayer): Now the state's internal layer is protected so you can access it if you need.

@FlxText
HACK: To make blurry centered/right justified texts look less blurry
   (The font size must NOT blur in left-align mode. Only sort of works ok for single line texts)

@FlxTilemap
UPGRADE: It can now be changed dynamically during gameplay.
UPGRADE: It has overlap and overlapArray functions to check against overlapping cores.

.widthInTiles [uint]: Now public
.heightInTiles [uint]: Now public
.tileSize [uint]: The tile dimensions, now public

.setTile(tileX, tileY, Index): Set the tile at X/Y to Index
.getTile(tileX, tileY, Index): Get the tile index at X/Y
[constructor] FlxTilemap(MapData, ..., WidthInTiles=0, HeightInTiles=0, FillIndex=0):
   Now if MapData==null, you to create an empty tilemap (e.g. to procedurally generate it using setTile)
   WidthInTiles, HeightInTiles and (optionally) FillIndex will create the tilemap accordingly.

.asCSVString(): Returns a CSV string of the map, in case you want to save it. ( FlxG.log(myMap.asCSVString()); )
.overlap(Core, Callback): Overlaps the tilemap gainst a core.
   The callback function format is:
   callbackFunc(core:FlxCore, tileIndex:uint, tileX:uint, tileY:uint, block:FlxBlock):void
   block is a TEMPORARY block, just so you can use pixel data (block.x/y/width/height). Don't do anything to it.
   Call this before FlxTilemap.collide()/collideArrays().
.overlapArray(CoreArray, Callback): Same as above but for an array of FlxCores
   




================================================================================================
BlxSubStateManager/BlxSubState USAGE EXAMPLE (not compile-tested, but to have an idea)
================================================================================================

Code: [Select]
class MyState extends FlxState {
private var _substMgr:BlxSubStateManager;
private var _substInventory:BlxSubState;
private var _substPaused:BlxSubState;

MyState() {
super();

//Create a sub state manager
_substMgr = new BlxSubStateManager;

//Paused will have the highest priority because it's added first
_substPaused = _substMgr.add(new BlxSubState);
_substPaused.add(new FlxText(... "PAUSED" ...));

//Then (if not paused) the inventory will have more priority than the game
_substInventory = _substMgr.add(new MyCustomBlxSubState);
_substInventory.haltsGame = false; //inventory shouldn't make the game stop

//...game stuff here...
}

override public function render():void {
super.render();
_substMgr.render(); //rendered after the state
}

override public function update():void {
//FIRST DO STUFF THAT ALWAYS NEEDS TO GET EXECUTED
if(FlxG.justPressed(FlxG.A))
_substInventory.toggle();

if(...something...)
_substPaused.toggle();

if(_substMgr.handle()) //if true, some substate was handled
return;

//IF NO SUB STATE WAS HANDLED, DO THE REGULAR GAME STUFF
super.update();
}
}

   

Pages: [1] 2 3