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 - Leebo

Pages: [1] 2
1
games / One Game a Day
« on: Fri, Jul 26, 2013 »
I started a project where I'm making one small game a day. I'm using Flixel.

http://www.kongregate.com/games/LeeboGames/one-game-a-day

WARNING: The games are not very good  :P

2
help / Multiple touch points
« on: Wed, Jun 19, 2013 »
This isn't Flixel specific, but I figured I'd ask here. I'm trying to make a simple multiplayer game for mobile and I want both players to be able to touch the screen and drag objects around.

How does that work in AS3?

When I want to code something to be dragged now, it's easy to just have the object's coordinates equal the mouse's coordinates with an offset for where on the object the initial click occurred.

I honestly haven't tested this on mobile yet, but my guess is that if you did the same thing and touched in two places at the same time you'd have a situation where the second touch wouldn't be recognized.

I'm completely ignorant here, so break it down for me even if it's something stupidly obvious. Every time I try to search for this stuff I always hit roadblocks of people talking about gestures and stuff.

3
games / Ludum Dare 26
« on: Sun, Apr 28, 2013 »
Just finished up my Ludum Dare game, made with Flixel of course.

http://www.ludumdare.com/compo/ludum-dare-26/?action=preview&uid=13975

4
help / Playing an embedded SWF
« on: Fri, Mar 29, 2013 »
Trying to play an embedded SWF file. The audio plays fine, but the "totalFrames" property is registering as 0, so the switchState triggers automatically.

Code: [Select]
package 
{
import org.flixel.*;
import flash.ui.Mouse;
import flash.events.Event;
import flash.display.MovieClip;

public class SponsorState extends FlxState
{
[Embed ( source = "assets/background.png" )] static public var bgGraphic:Class;
[Embed(source = "assets/ag_intro_2011.swf")] private var   SwfClass:Class;
private var movie:MovieClip;

public function SponsorState()
{
super();
}

override public function create():void
{
movie = new SwfClass();
FlxG.stage.addChild( movie );
movie.addEventListener(Event.ENTER_FRAME, next);
Mouse.show();
}

override public function update():void
{
super.update();
}

private function next(e:Event):void
{
if ( movie.currentFrame >= movie.totalFrames )
{
movie.removeEventListener(Event.ENTER_FRAME, next);
FlxG.stage.removeChild( movie );
FlxG.switchState( new IntroState() );
}
}
}

}

5
help / Preloader and showing ads
« on: Wed, Mar 13, 2013 »
I want the preloader to show an ad over it, and I want the preloader to stay there for the minimum 10 seconds before moving on. However, the ad just shows and it goes into the game states before 10 seconds have gone by. Why isn't minDisplayTime working?

Yes, I have tried opening it on a browser.

Here's my preloader class

Code: [Select]
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
    import org.flixel.system.*;
import org.flixel.*;
import com.as3.gpsapi.*;
 
public class Preloader extends FlxPreloader
{

public function Preloader():void
{
className = "Main";
super();
}

override protected function create():void
{
super.create();

var CPMStarContentSpotID:String = "";
var adBox:AdLoader = new AdLoader(CPMStarContentSpotID);

adBox.width = 300;
adBox.height = 250;
adBox.x = ( FlxG.width / 2 ) - ( adBox.width / 2 );

addChild( adBox );

minDisplayTime = 10;
}
}
}

6
help / Adding Display Object
« on: Tue, Mar 12, 2013 »
I'm trying to add logos for a sponsor, and they are standard Flash display objects, so they don't seem to play nice with Flixel.

I've read this http://www.photonstorm.com/archives/1530/flash-game-dev-tip-11-the-flixel-display-list-explained

And I still have no idea what to do.

I tried

Code: [Select]
FlxG.stage.addChild( logo );
but this results in the logo being placed on top of everything, including the mouse, as expected

How can I get it above my gameplay and below my mouse (which happens to just be a custom FlxSprite cursor, which I'm sure will complicate things).

7
help / [SOLVED] FlxSprite collision stuff
« on: Sun, Mar 3, 2013 »
I have a FlxSprite that has its own FlxSprites inside it.

When the FlxSprite collides into walls, the internal FlxSprites don't stop and go into the wall ever so slightly before coming back into place.

Short of calling a collision on the internal FlxSprites, where can I put the x/y and velocity x/y info into the FlxSprite's code to keep them in the same place all the time.

I thought putting it in the postUpdate portion would do it, but it doesn't.

Here's the code if it helps, though it's pretty messy

Code: [Select]
package 
{
import org.flixel.*;

public class Crusher extends FlxSprite
{
public const STATIONARY:uint = 0;
public const HORIZONTAL:uint = 1;
public const VERTICAL:uint = 2;

public const LEFT:uint = 0;
public const RIGHT:uint = 1;
public const UP:uint = 2;
public const DOWN:uint = 3;

public var initial:Boolean = true;
public var speed:int = 200;
public var movement:uint = 0;
public var direction:uint = 0;
public var movementTimer:Number = 0;
public var black:FlxSprite = new FlxSprite( 0, 0 );
public var red:FlxSprite = new FlxSprite( 0, 0 );
private var cooling:Boolean = false;
private var timer:int = 0;

public function Crusher( X:Number, Y:Number )
{
super( X, Y, Registry.crusherGraphic );

width = 32;
height = 32;

black.makeGraphic( width, height, 0xFF000000 );
red.makeGraphic( width, height, 0xFFaf2929 );

black.x = X;
black.y = Y;
red.x = X;
red.y = Y;

maxVelocity.x = 1000;
maxVelocity.y = 1000;
}

override public function update():void
{
super.update();
handleMovement();
black.update();
red.update();

timer++;

if ( timer == 2 )
{
timer = 0;

if ( cooling )
{
red.alpha -= 0.02;

if ( red.alpha <= 0.8 )
{
cooling = false;
}
}

else
{
red.alpha += 0.02;

if ( red.alpha >= 1 )
{
cooling = true;
}
}
}
}

private function handleMovement():void
{
if ( movement == HORIZONTAL )
{
if ( initial ) direction = RIGHT;
if ( !initial ) direction = LEFT;

movementTimer += FlxG.elapsed;

if ( movementTimer >= 0.5 )
{
if ( direction == RIGHT )
{
acceleration.x = speed;
}

if ( direction == LEFT )
{
acceleration.x = -speed;
}

movementTimer = 0;
}
}
}

override public function postUpdate():void
{
super.postUpdate();
black.postUpdate();
red.postUpdate();
black.x = x;
black.y = y;
black.velocity.x = velocity.x;
black.velocity.y = velocity.y;
red.x = x;
red.y = y;
red.velocity.x = velocity.x;
red.velocity.y = velocity.y;
}

override public function draw():void
{
if ( onScreen() )
{
black.draw();
red.draw();
super.draw();
}
}

}

}

8
I want to call FlxG.overlap on bullets that are overlapping with certain tiles.

Collide causes weird things to happen when I stand in certain places... for reasons unknown.

I want to test overlap, but when I do FlxG.overlap( bullets, level, callbackFunction ), it thinks the overlap is happening all the time, anywhere in the level, which makes sense. I only want to check overlap with some of the tiles, and not others.

Is there a way to do that?

9
help / [SOLVED] FlxGroup acting strangely...
« on: Tue, Feb 26, 2013 »
I have a really weird problem, and maybe I did something stupid, but I can't see it after staring at it for so long.

I have a bullet manager FlxGroup

Code: [Select]
package 
{
import org.flixel.*;

public class BulletManager extends FlxGroup
{
private var bullet:Bullet;
private var index:uint = 0;
private var i:int = 0;

public function BulletManager()
{
super();

for ( i = 0; i < 10; i++ )
{
bullet = new Bullet();
add( bullet );
}
}

public function fire( bx:int, by:int, facing:int ):void
{
members[ index ].fire( bx, by, facing );

index++;

if ( index > members.length - 1 )
{
index = 0;
}
}
}

}

Everything works fine if I use a power of 2 as the for loop condition. So if I try to create 8, 16, 256 bullets, etc, no issues.

If I give it some other number, such at the 10 that I want, it creates those 10 no problem, but then it fills the FlxGroup with undefined members up to the next power of 2.

So, if I try to make 10, it makes 10 bullets, then adds 6 undefined, and my fire function doesn't work because when it gets to index = 11 it tries to shoot an undefined instead of going back to zero.

What am I doing wrong?

10
help / Clouds, scrollFactor, onScreen, etc
« on: Sat, Feb 23, 2013 »
I'm making an auto-runner game for practice and want to have some clouds float by randomly.

In my auto-runner, the player is always moving to the right, the platforms are stationary, and get shifted off screen to the right when they are too far left, and the background sky image has a scrollFactor of 0.

All that works nicely.

I added some random clouds and gave them random scrollFactors and that's all fine and dandy until they scroll off the screen. Then I can't really figure out a good way to get them back to the right side of the screen so they can scroll across again.

I tried the onScreen() function, but it doesn't seem to work.

Code: [Select]
for ( i = 0; i < members.length - 1; i++ )
{
if ( !members[ i ].onScreen() )
{
members[ i ].x = PlayState.focusX + 720;
members[ i ].y = randomNumber( 0, 250 );
members[ i ].scrollFactor.x = randomNumber( 20, 30 ) / 100;
}
}

In that code, PlayState.focusX is the world X position of the player. I was trying to make it so that if the clouds scroll off screen, they get put 720 right of the player and then randomly scroll off again.

11
I'm not sure why this seems to be a default thing, but I don't want the zero key to change the volume... any way to stop that from happening?

12
games / Farflung, my first "complete" game
« on: Tue, Feb 5, 2013 »
I recently finished up working on a game I started in late January called Farflung.

It's a simple arcade game where the main game mechanic is flinging a ball to destroy dots on the screen.

I'm in the final polishing phase and hoping to get a small sponsorship if possible.

Here's the trailer. http://www.youtube.com/watch?v=wYR1dEkWBJ8

It's made with Flixel, and I couldn't have done it without all the help I've gotten from the Flixel boards over the last 6 months of or so while I learned how to use it.

Thanks, Flixel community!

13
help / [SOLVED] How to use the "FlxG.state" property
« on: Sun, Feb 3, 2013 »
I want to make a button that restarts your current state, regardless of what that state is.

Is there a way to do it with just FlxG.state and FlxG.switchState()?

I tried this:

Code: [Select]
if ( FlxG.state == PlayState )
{
FlxG.switchState( new PlayState() );
}

if ( FlxG.state == PlayState2 )
{
FlxG.switchState( new PlayState2() );
}

if ( FlxG.state == PlayState3 )
{
FlxG.switchState( new PlayState3() );
}

But it doesn't like that

14
help / [SOLVED] Music files and the size of the game
« on: Sat, Feb 2, 2013 »
This might not be Flixel-specific, but I trust you guys  :)

I have a game where 3 different playstates use the same music.

For some reason, the file grew about 1.2MB each time I created a new playstate. I'm guessing the music is responsible, because no other part of the game would be that big.

I thought the game wouldn't need to grow its file size to use a song in different playstates. In response to that line of thinking, I made all the music  public static variables of the TitleState, and just had the playstates play from the titlestate.

No change, the file size remains bloated.

Any thoughts on how to do it so it doesn't duplicate the music size for each state I use it?

15
help / [SOLVED] issues with drawLine
« on: Thu, Jan 3, 2013 »
I'm trying to practice a bit and decided to remake Minesweeper with just code, no outside assets.

I create sprites for all the mines and flags and I draw the little symbols using drawLine.

The problem is that the lines are getting drawn on both the flags and the mines, so they all look like a combination of the two.

This is what it looks like when flags and mines are both set to invisible (which is default)



This is what it looks like when flags are invisible but mines are set to visible.



And this is what it looks like when flags are visible and mines are invisible.



It looks to me like both sets of lines are being drawn on both sets of sprites, but I have no idea how that would happen.

Here is the whole create function for my PlayState

Code: [Select]
override public function create():void
{
FlxG.mouse.show();

//set up difficulty levels

if ( TitleState.intDifficulty == 0 )
{
intGridH = 9;
intGridW = 9;
intMineMax = 10;
intMineCalc = 8;
}

if ( TitleState.intDifficulty == 1 )
{
intGridH = 16;
intGridW = 16;
intMineMax = 40;
intMineCalc = 8;
}

if ( TitleState.intDifficulty == 2 )
{
intGridH = 16;
intGridW = 30;
intMineMax = 99;
intMineCalc = 8;
}

//create the grid of squares

for ( i = 0; i < intGridH; i++ )
{
for ( j = 0; j < intGridW; j++ )
{
sprSquare = new Square( j * intSize + intMarginS, i * intSize + intMarginT, intSize );
grpSquares.add( sprSquare );
}
}

//randomly place mines and draw them

while( intMineCount < intMineMax )
{
for ( i = 0; i < grpSquares.length; i++ )
{
if ( ( grpSquares.members[i].boolMine == false ) && ( intMineCount < intMineMax ) )
{
intMineChance = randomNumber( 0, intMineCalc - 1 );

if ( intMineChance == 0 )
{
grpSquares.members[i].boolMine = true;
intMineCount++;
sprMine = new FlxSprite( grpSquares.members[i].x, grpSquares.members[i].y );
sprMine.makeGraphic( 24, 24, 0x00FFFFFF );
sprMine.drawLine( 12, 4, 20, 12, 0xFFFFFF, 2 );
sprMine.drawLine( 20, 12, 12, 20, 0xFFFFFF, 2 );
sprMine.drawLine( 12, 20, 4, 12, 0xFFFFFF, 2 );
sprMine.drawLine( 4, 12, 12, 4, 0xFFFFFF, 2 );
sprMine.drawLine( 5, 5, 19, 19, 0xFFFFFF, 2 );
sprMine.drawLine( 19, 5, 5, 19, 0xFFFFFF, 2 );
sprMine.visible = false;
grpMines.add( sprMine );
}

else
{
grpSquares.members[i].boolMine = false;
grpMines.add( null );
}
}
}
}

//draw flags for all squares

for ( i = 0; i < intGridH; i++ )
{
for ( j = 0; j < intGridW; j++ )
{
sprFlag = new FlxSprite( j * intSize + intMarginS, i * intSize + intMarginT );
sprFlag.makeGraphic( 24, 24, 0x00FFFFFF );
sprFlag.drawLine( 12, 4, 12, 20, 0xFF0000, 2 );
sprFlag.drawLine( 12, 4, 8, 8, 0xFF0000, 2 );
sprFlag.drawLine( 8, 8, 12, 8, 0xFF0000, 2 );
sprFlag.drawLine( 8, 20, 16, 20, 0xFF0000, 2 );
sprFlag.visible = false;
grpFlags.add( sprFlag );
}
}

//create text field for each square

for ( i = 0; i < intGridH; i++ )
{
for ( j = 0; j < intGridW; j++ )
{
txtSquare = new FlxText( j * intSize + intMarginS, i * intSize + intMarginT, 24, "" );
txtSquare.setFormat( null, 16, 0xFFFFFF, "center" );
txtSquare.visible = false;
grpSquareTexts.add( txtSquare );
}
}

//count adjacent bombs for each square and assign to text fields

for ( i = 0; i < grpSquares.length; i++ )
{
if ( grpSquares.members[i].x != intMarginS )
{
if ( grpSquares.members[i - 1].boolMine == true )
{
grpSquares.members[i].intTouching++;
}
}

if ( grpSquares.members[i].y != intMarginT )
{
if ( grpSquares.members[i - intGridW].boolMine == true )
{
grpSquares.members[i].intTouching++;
}
}

if ( grpSquares.members[i].x != intMarginS + ( intSize * intGridW ) - intSize )
{
if ( grpSquares.members[i + 1].boolMine == true )
{
grpSquares.members[i].intTouching++;
}
}

if ( grpSquares.members[i].y != intMarginT + ( intSize * intGridH ) - intSize )
{
if ( grpSquares.members[i + intGridW].boolMine == true )
{
grpSquares.members[i].intTouching++;
}
}

grpSquareTexts.members[i].text = grpSquares.members[i].intTouching.toString();
}

//add objects

add( grpSquares );
add( grpMines );
add( grpFlags );
add( grpSquareTexts );
}

And here are the relevant parts which create and draw the flags and bombs to make it easier to home in on them

Code: [Select]
//randomly place mines and draw them

while( intMineCount < intMineMax )
{
for ( i = 0; i < grpSquares.length; i++ )
{
if ( ( grpSquares.members[i].boolMine == false ) && ( intMineCount < intMineMax ) )
{
intMineChance = randomNumber( 0, intMineCalc - 1 );

if ( intMineChance == 0 )
{
grpSquares.members[i].boolMine = true;
intMineCount++;
sprMine = new FlxSprite( grpSquares.members[i].x, grpSquares.members[i].y );
sprMine.makeGraphic( 24, 24, 0x00FFFFFF );
sprMine.drawLine( 12, 4, 20, 12, 0xFFFFFF, 2 );
sprMine.drawLine( 20, 12, 12, 20, 0xFFFFFF, 2 );
sprMine.drawLine( 12, 20, 4, 12, 0xFFFFFF, 2 );
sprMine.drawLine( 4, 12, 12, 4, 0xFFFFFF, 2 );
sprMine.drawLine( 5, 5, 19, 19, 0xFFFFFF, 2 );
sprMine.drawLine( 19, 5, 5, 19, 0xFFFFFF, 2 );
sprMine.visible = false;
grpMines.add( sprMine );
}

else
{
grpSquares.members[i].boolMine = false;
grpMines.add( null );
}
}
}
}

Code: [Select]
//draw flags for all squares

for ( i = 0; i < intGridH; i++ )
{
for ( j = 0; j < intGridW; j++ )
{
sprFlag = new FlxSprite( j * intSize + intMarginS, i * intSize + intMarginT );
sprFlag.makeGraphic( 24, 24, 0x00FFFFFF );
sprFlag.drawLine( 12, 4, 12, 20, 0xFF0000, 2 );
sprFlag.drawLine( 12, 4, 8, 8, 0xFF0000, 2 );
sprFlag.drawLine( 8, 8, 12, 8, 0xFF0000, 2 );
sprFlag.drawLine( 8, 20, 16, 20, 0xFF0000, 2 );
sprFlag.visible = false;
grpFlags.add( sprFlag );
}
}

16
help / Can someone walk me through how to handle saves?
« on: Sun, Nov 25, 2012 »
I have 7 variables I want the player to be able to save. One is a high score int, and the other 6 are booleans for achievements.

I also want to be able to delete the save file from the main menu.

What do I need to be able to do that? I've never handled any saving before.

17
help / FlxSprite collides, but there's some "give"
« on: Tue, Nov 13, 2012 »
I'm working on a platformer and the collide function works fine for keeping the player on the ground, and he can't walk totally through walls, but when he's running he doesn't stop at the edge of the wall, but goes into it a little bit.



I'm thinking this is because of the way I handle the player's movement on the X axis, which is to simply add or subtract 10 from the X value when the player is holding the arrow keys. So it's like it's adding 10, but can't go further and just kinda stays in the wall until you let go.

Can someone think of a good way to not let him "penetrate" the wall like that?

18
help / How to check which side is colliding?
« on: Thu, Nov 8, 2012 »
I'm trying to make a simple breakout game as practice and I can't figure out how to handle the collisions for the ball when it's touching different sides of the blocks.

I have this to see if the ball is touching any blocks

Code: [Select]
FlxG.overlap( ball, blocks, blockHit );
and then this is the callback

Code: [Select]
public function blockHit(s1:FlxSprite, s2:FlxSprite):void
{
if ( ( s2.isTouching( FlxObject.UP ) ) || ( s2.isTouching( FlxObject.DOWN ) ) )
{
s1.velocity.y *= -1;
}

if ( ( s2.isTouching( FlxObject.LEFT ) ) || ( s2.isTouching( FlxObject.RIGHT ) ) )
{
s1.velocity.x *= -1;
}

s2.visible = false;
s2.solid = false;
}

The lower part that makes the blocks disappear works fine, but the part where I'm trying to check which side of the block the ball is touching doesn't work. The ball barrels through unaffected.

19
help / FlxG.random() [SOLVED]
« on: Sun, Oct 14, 2012 »
Maybe my brain has turned to mush, because I haven't programmed for a month or so, but what the hell am I doing wrong here?

I want random numbers, but FlxG.random() seems to produce 0 every single time.

rand is declared as an int.

Code: [Select]
rand = FlxG.random();
trace( rand );

I have that in a for loop that runs 64 times, and I get 64 zeroes. What's going on? I don't think I'm using FlxG.random() differently that I used to in past projects.

20
help / [SOLVED] FlxEmitter child inside FlxSprite
« on: Tue, Jul 17, 2012 »
I'm trying to put a FlxEmitter inside a FlxSprite so that when the FlxSprite's explode boolean is triggered it disappears and the FlxEmitter goes off.

I know everything else in the code works because the "visible = false" part is properly making the asteroids disappear when "explode" is set to true in my PlayState, but the FlxEmitter does not activate.

Just to be clear, I know the toggling of the visibility isn't affecting it, because even if I comment out the visibility line, I get the no collisions effect and still don't get a FlxEmitter explosion.

Code: [Select]
package 
{
import org.flixel.FlxSprite;
import org.flixel.FlxObject;
import org.flixel.FlxEmitter;
import org.flixel.FlxParticle;

public class Asteroid extends FlxSprite
{
[Embed(source = "assets/asteroid.png")]
private var AsteroidGraphic:Class;

public var explode:Boolean = false;

private var astEmitter:FlxEmitter;
private var astParticle:FlxParticle;

public function Asteroid(X:Number = 0, Y:Number = 0)
{
super(X, Y);
loadGraphic(AsteroidGraphic, true, false, 32, 32);
addAnimation("1", [0, 1, 2, 3, 4, 5, 6, 7], 6, true);
play("1");

astEmitter = new FlxEmitter( 0, 0, 12 );

for ( var i:int = 0; i < 12; i++ )
{
astParticle = new AstParticle();
astEmitter.add(astParticle);
}


}

override public function update():void
{
if ( explode == false )
{
visible = true;
allowCollisions = FlxObject.ANY;
}

if ( explode )
{
visible = false;
allowCollisions = FlxObject.NONE;
astEmitter.at(this);
astEmitter.start(true, 10, 0, 12 );
}

super.update();
}
}
}

Pages: [1] 2