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

Pages: 1 ... 3 4 [5] 6 7 ... 75
help / Re: Finding an object based on his name string.
« on: Thu, Nov 10, 2011 »
Never touched eval, so *shrug*

help / Re: Finding an object based on his name string.
« on: Thu, Nov 10, 2011 »

You might have to cast it to whatever data type it is first though: spaceInvader(this["Obj1"]).someMethod() for example

I'll start you off, you'll have to fill in the blanks:

The trick to Qix isn't what you see on-screen, it's what you don't see.

Imagine a bitmap, the size of your game. Entirely black. You draw a white line around the edges (so a rectangle, but you don't fill in the middle). Then start the player on that line. Check for a key press. Going left? Do a getPixel on the pixel x - 1 from the player. Is it white? If so you can move the player. Repeat for all 4 directions.

As for filling an area: If they are pressing a key to go into the screen, check the pixel they will move in to. If it's black, take a copy of your "screen" bitmap. Then move them 1 pixel into it, drawing a single pixel of a new colour down (say red). Keep checking key presses - if they move into a pixel containing red, they are dead. If a baddie moves into a red line, they are dead. If they collide with a white pixel again then they have made a complete segment. Use the bitmapData's flood fill method to fill in this area with a new colour (blue?) and REPLACE the red line you drew with white. Then copy this bitmap over the top of the one you had previously before they started moving. Loop through your new bitmap counting blue pixels to get the % complete.

What you will end-up with is a strange looking bitmap full of white lines and blue boxes everywhere, but the trick is just to always check the pixel they are moving in to.

Visually what you display on-screen doesn't have to look like this of course, you're just using this as an invisible collision grid. You could technically do it using an array of values as well, but I find that the floodFill method will make this much easier for you :)

help / Re: Have webcam in the game?
« on: Wed, Nov 9, 2011 »
Why is it bad? I am using lot of "normal flash" content. Actually as much as possible :) I think Flixel is great for game itself, but AS3 / Flash IDE is much more flexible for hud, chat, gamelog..

In those examples you're just using it for UI. I doubt very much if the need for a webcam is purely on a UI level. Once you start to need to mix MovieClips and normal Sprites into your "game" I fail to see the need to carry on using flixel at all.

help / Re: Have webcam in the game?
« on: Wed, Nov 9, 2011 »
I would say be careful here. Once you start to cross the line into "normal Flash" too far, flixel becomes a burden, not a benefit. If it's literally just a webcam you need then it's easy to insert and control. But question the approach first.

You can draw GridSpot inside of itself quite happily, providing it extends Sprite.

"Would I have to addChild(Gridspot) inside of GameBoard which would have to extend sprite?  Why???"

You can only call addChild in a class that extends a display object. The parent - child relationship is for ease of use. Your GameBoard sprite can contain ALL of the GridSpot children. Then you can do really useful things like "board.visible = false" to turn off the whole grid, at once. This is why you don't add children directly to the stage, but put them into parents first.

So your game is a sprite, then it can contain a sprite for the board (which itself contains all the board pieces), it can contain a sprite with all of the HUD stuff in, maybe another one with a Mochi leaderboard. You get the idea.

help / Re: z sort with collisions
« on: Tue, Nov 8, 2011 »
Zombies Ate my Neighbours just uses a simple grid system - just like a tilemap really, only you sort depth on the Y value. Have a look at the following screen-shot - you'll see it adheres to a 16x16 pixel grid perfectly. The sprites are then anchored to blocks around their feet - the base block (yellow in this screen shot) is the one collision (and depth sorting) is performed against.

The rest of it is just really clever visual trickery based on some stunning pixel art assets. But from a math point of view, there's no real depth at all.

help / Re: Problem with sprite position
« on: Tue, Nov 8, 2011 »
If you add "red" to your State, then add "blue", blue will always be on-top of red, because that is the order in which you added them.

If you need to change this order dynamically, in-game, you have to give your sprites a new property (z-index?) and use FlxGroup sort to filter them. By default sort() sorts on the Y axis value, which isn't always the result you need.

help / Re: Preloading using the Flash IDE
« on: Tue, Nov 8, 2011 »
The reason the pre-loader doesn't work is because your Game class has a direct reference to your game, i.e. it needs to create it (and all of its assets) on that frame.

The set-up should go like this:

Code: [Select]
import flash.display.Sprite;
import reflex.Core.GameState;

public class Main extends Sprite

public function Main():void
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);

private function init(e:Event = null):void
removeEventListener(Event.ADDED_TO_STAGE, init);

// entry point

var game:Game = new Game;





Set this as your Document Class in Flash Builder then set className to "Main" in your preloader. I don't use FlashBuilder, but this is how I set up all of my games in FlashDevelop, and it should be similar.

As for the lag - check the project frame rate in FB is correct. Also *always* compile in Release mode once you're done testing, by default I expect FB compiles in Debug mode, which is slower. Debug mode allows you to trace things out, Release doesn't.

help / Re: Problem with sprite position
« on: Tue, Nov 8, 2011 »
It's all down to the order in which they are added. If you need to constantly shift them, i.e. based on their Y value give ones further down the screen a higher priority (appear on-top) then put them in an FlxGroup and call is sort method. Voila :) If that isn't quite what you need, modify it until it is.

I'd use Minimal Comps personally. They still use display list objects though, so you'll have to be clever in how you add them to the display. But otherwise they will do what you need (light-weight, fully featured components)

help / Re: Preloading using the Flash IDE
« on: Tue, Nov 8, 2011 »
Don't use the IDE to compile :) Problem solved.

Wow, that's an inheritance chain and a half :)

I don't understand why you're passing in references to stage everywhere. The structure of the display list is a simple parent - child one. So to use your example:

1) Main needs to extend a Sprite, so you can add stuff to it
2) Your Game needs to extend Sprite
3) I would make your GameBoard either extend Sprite, or contain a sprite within it that children are added to
4) Your GridSpot instances - depending on what they need to do they should probably extend Sprite too.

Then you can do:

Main - addChild(game)
Game - addChild(board)
Board - addChild(gridSpot) x however many you need

You CANNOT do addChild unless the class extends a display list object (i.e. a Sprite or similar), otherwise everything is free game

addChild can only be used in a class that extends a display object (like Sprite or MovieClip).

You don't have to do it in Main though - you could create a new class called "Game" which extends Sprite, and do it from there. Or create a class called "Canvas" maybe, and add a reference to it into a Registry, then you could access it from anywhere (Registry.canvas.addChild())

What error does it throw?!

My guess is that the array index you're adding to the display list doesn't contain a valid Sprite.

Try this:

Code: [Select]
public function CellPiece()
graphics.beginFill(0xff0000, 1);
x = int(Math.random() * 300);
y = int(Math.random() * 300);

But most of all, post the error :)

help / Re: Flixel Power Tools
« on: Thu, Nov 3, 2011 »
Sounds to me like you don't have your Project set-up correctly in FlashDevelop. It will only auto-complete source code it has direct access to. Have you created a project, put flixel and the tools into your src folder, etc? If you've done all this and SOME stuff auto-completes but not all, then you might just need to rebuild the Intrinsic cache - it's on a drop-down menu in FD somewhere, have a hunt!

help / Re: FlxButton do not work
« on: Tue, Nov 1, 2011 »
That's the right place to create them.

Does the button work if you remove the loadGraphic call?

Also which version of Flixel is this?

help / Re: FlxButton do not work
« on: Tue, Nov 1, 2011 »
What class is the above in? It would need to be in an FlxState (or an FlxGroup)

help / Re: Power tools question
« on: Tue, Nov 1, 2011 »
It's only used when the class in question is a plugin :) Not all of the tools are, some are just classes or statics and don't run through Flixels plugin system.

Pages: 1 ... 3 4 [5] 6 7 ... 75