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 ... 73 74 [75]
1481
help / Re: Falling sprite jitters like mad
« on: Tue, Jan 26, 2010 »
I did try your revised getScreenXY, believe me I did! I've spent hours trying to solve this and just work out how it all operates under the hood :)

I've actually got a set of values now which I feel work pretty well together, so I'm getting close. I'm finding the way it handles "physics" very limiting at the moment, but that's a project for another day. Right now I need to get this game finished pronto! :)

1482
help / Re: Falling sprite jitters like mad
« on: Tue, Jan 26, 2010 »
I ripped out everything I had added / changed, rolled back to a default Flixel version fresh from Github, and then put the exact same values for the sprite / camera as used in Mode.

And it works ok - the scrolling is smooth (way too fast, but smooth) and the sprite doesn't flicker on bit. Those values must be "just right" to fit into the timing / rounding threshold needed. Which is a shame because in this game I need the player to "float" down, like a bubble.. not sink like a lead bomb ala Mode.

It's a start ... let's see what can be tweaked.

1483
help / Re: Falling sprite jitters like mad
« on: Tue, Jan 26, 2010 »
Hi guys,

Thanks for both of your suggestions. Sadly neither work - modifying the getScreenXY is a nice idea, but the camera methods use the FlxCore x/y values directly (bypassing that), the render stage used getScreen but the problem has already been cause by that point :(

I have tried loads of lerp/adjust settings cai! You're right though, the issue is camera related for sure, in relation to the x/y coords of the FlxSprite it is tracking.

So far I have tried:

1) Totally disabling the double-buffer, so it writes to one bitmap only. No dice.

2) Replaced the "doFollow()" method with my own, that cast the coords to ints before rendering. This helped, but the sprite still flickers as it gains acceleration - but once it hits maxVelocity it is stable.

3) In the FlxSprite update() method these two lines sit at the bottom:

Code: [Select]
x += (velocity.x = FlxG.computeVelocity(velocity.x, acceleration.x + thrustComponents.x, drag.x, maxVelocity.x)) * FlxG.elapsed;
y += (velocity.y = FlxG.computeVelocity(velocity.y, acceleration.y + thrustComponents.y, drag.y, maxVelocity.y)) * FlxG.elapsed;

This is what causes the jitter. If I add this:

Code: [Select]
x = Math.round(x);
y = Math.round(y);

After them, then I get pixel perfect smooth scrolling sprites, every time. However now all the tile collision tests are screwed (landing on something often causes it to get stuck there). Also all of the nice smoothing (acceleration / deceleration) has of course gone because this value needs to progress smoothly.

I'm at a bit of a loss as to what to try next to be honest.

1484
help / Re: Falling sprite jitters like mad
« on: Mon, Jan 25, 2010 »
Thanks - that seemed to help sometimes! ... it's weird, as if there is a 1 in 3 chance of it getting into a "smooth" drop, and when it does it looks great, but the other 2 times it still jitters lots.

I notice that if I enable collision on the tilemap it has a much higher chance of jittering. If I disable that then your code above nearly always causes a smooth drop.

1485
help / Re: Falling sprite jitters like mad
« on: Mon, Jan 25, 2010 »
Yeah I saw your post - it's certainly a similar issue. I've spent hours on it this evening trying to resolve it, and haven't got anywhere yet. I'm pretty sure it's a rounding issue. Time to download some sample games and see if they have the same issue.

1486
help / Falling sprite jitters like mad
« on: Mon, Jan 25, 2010 »
I've got a Tilemap that scrolls vertically. The FlxSprite player starts at the top and drops down.

It's working fine but for some reason the sprite is being drawn quite strangely - very often (but not all the time) it's as if the sprite is drawn 1 pixel lower than it should, and then a split second later is drawn 1 pixel higher again. The end result is that it looks like it's jiggling up and down (by 1 pixel) every time it updates.

It makes the sprite very flickering. I'm actually at a loss how to fix it. When the sprite collides and lands on a tile the flicker stops. If the sprite lands and moves left/right it doesn't flicker at all. It's just when falling.

I have tried various Y values for velocity, max velocity and accleration with no success. My guess is it could be a "rounding" issue - i.e. the Y value is a Number but of course with a bitmap engine it has to round to whole pixels, and sometimes it draws one line too far down. But I don't know how to fix it - it gives the visual effect of being "interlaced".

Has anyone seen this before / have any clues? The game is going perfectly other than this part! (the tilemap doesn't flicker at all)

Cheers,

Rich

1487
I think you're on the right track already - give it a negative acceleration, and in the bullets update function check to see if the Y velocity has hit the "peak" of your arc, and then reverse the acceleration to be positive.

1488
One thing I'd just like to add - because it caught me out big-time less than an hour ago - setCallback functions don't fire unless you run collide() on your map each update.

1489
help / Re: Co-ordinate Head Hurting
« on: Sun, Jan 24, 2010 »
To position an FlxSprite in the bottom right corner of a 1000x1000 map you would set its coordinates to be approx. 984x984 - this is assuming your tile map is using 16x16 sized tiles - the 984 gives the sprite a chance to not overlap with the bottom right-hand corner edge of your map. If you use a bigger/smaller tile size, then adjust accordingly.

You probably can't see the sprite because you haven't set the camera to follow it:

Code: [Select]
FlxG.follow(player);
Would do so, unless you've tried that and meant something else?

1490
help / Re: Help with HelloWorld
« on: Sat, Jan 23, 2010 »
Tools - Settings - Click AS3Context on the left -  Scroll to the "Language" section on the right - "Flex SDK Location" - edit it.

1491
help / Re: Help with HelloWorld
« on: Sat, Jan 23, 2010 »
You need to point FlashDevelop to the path of the Flex SDK.
It's telling you where to do this in the error.

Do as it says and it will at least try to compile, then you'll know if you have any errors or a working game.

1492
help / Re: Flixel in Flash Builder 4?
« on: Sat, Jan 23, 2010 »
24 fps is the maximum a CS5 iPhone app can run at (this may of course change with upcoming betas)

I achieved that with one animated character moving around a 3-layer tile map (one collision layer, the other 2 were background parallax effect layers). Character was being moved with the accelerometer.

1493
help / Re: Flixel in Flash Builder 4?
« on: Sat, Jan 23, 2010 »
I'm getting between 20 and 24 fps. Believe me, that's good.

1494
help / Re: Disabling the Pause Screen
« on: Fri, Jan 22, 2010 »
Just set it to a blank layer:

Code: [Select]
this.pause = new FlxLayer();
This is in whatever extends FlxGame

1495
Hiya - thanks for the welcome :) without wanting to hijack this thread I just wanted to say how impressed I am with Flixel 2.0 - it has come on a long way! Really excited to be working with it.

1496
Oh it's also worth pointing out that I didn't look at using a Layer instead - this should be a more elegant solution to using pre/post updates.

1497
Hiya,

Ok I had a little play with this.

If you just want to use this for visual effects (i.e. not to actually emit FlxSprites!) then the following worked for me:

This is all inside your PlayState.as:

Add a bitmapData, your particles will be drawn here:

Code: [Select]
b = new BitmapData(640, 480, true, 0xffffff);
Create an emitter and renderer, here's the one I used:

Code: [Select]
emitter = new Emitter2D(new SteadyClock(1));
renderer = new BitmapRenderer(b);
renderer.addEmitter(emitter);

var d:DisplayObjectClass = new DisplayObjectClass(latte);
var position:Position = new Position(new Line(0, 0, 640, 0));
var velocity:Velocity = new Velocity(new SinglePoint(0, 4));

emitter.addInitializer(d);
emitter.addInitializer(position);
emitter.addInitializer(velocity);

var move:Move = new Move();
var deathZone:DeathZone = new DeathZone(new RectZone(0, 0, 640, 400), true);

emitter.addAction(move);
emitter.addAction(deathZone);

Note that it will render to the bitmapData (b) we created above. The rest is just standard stuff taken from the Stardust tutorial.

The one thing worth pointing out is the class given to the DisplayObjectClass - in this case its called "latte" which is just an embedded Bitmap with the class name set to "latte" (I was drinking one at the time!)

Ok so that's it.. back to your PlayState.as:

1) Call emitter.step() in your update function

.. and now just decide when to apply the particles.

You can choose to do it in 3 places.. preProcess, the update phase or postProcess. Depending on your set-up depends which is best. For example here is my preProcess with a blur effect:

Code: [Select]
override public function preProcess():void
{
b.applyFilter(b, new Rectangle(0, 0, b.width, b.height), new Point, new BlurFilter(6, 6, 1));
screen.drawFromBitmapData(b, 0, 0);
}

Now I admit I had to create the "drawFromBitmapData" method in FlxSprite, as simply updating the pixels value caused the sprite reset, which ****ed it up. So here is the method I added:

Code: [Select]
/**
* This function merges one bitmapData with the current sprite
* This function is NOT intended to replace <code>render()</code>!
*
* @param B The bitmapData you want to stamp onto this sprite.
* @param X The X coordinate of the brush's top left corner on this sprite.
* @param Y They Y coordinate of the brush's top left corner on this sprite.
*/
public function drawFromBitmapData(b:BitmapData, X:int=0, Y:int=0):void
{
_p.x = X;
_p.y = Y;
_r2.width = b.width;
_r2.height = b.height;
_pixels.copyPixels(b,_r2,_p,null,null,true);
_r2.width = _pixels.width;
_r2.height = _pixels.height;
calcFrame();
return;
}

Very simple stuff - just merges the given bitmapData (in this case your particles) with the current screen buffer.

So if you call this in preProcess it will do it before all other FlxSprites etc are added. If you call it during postProcess it sticks them on-top of the screen. I don't know where it'll work best for you.

So ok not quite that straight forward - but ultimately it works ok :)

Cheers,

Rich

1498
You are using the Stardust DisplayObjectRenderer, which probably isn't the best choice for this as although FlxState extends Sprite, it isn't really a true "sprite" as everything is still rendered to FlxG.buffer (a BitmapData). You should try looking at the Stardust Bitmap renderer, and giving it the FlxState.screen to draw to.

1499
help / Re: Flixel in Flash Builder 4?
« on: Fri, Jan 22, 2010 »
Yeah, and then you could link in the AIR2 SWC if you want to access the new APIs in there.

1500
help / Re: Flixel in Flash Builder 4?
« on: Fri, Jan 22, 2010 »
I can't see any reason why it shouldn't work with FB4. I'm using it with the AIR 2.0 libs that are part of CS5 (Beta Drop 10), so I can access iPhone TouchEvents, and it's compiling and running perfectly.

Actually without breaching Adobe NDA all I'd really like to say is that Flixel running on the iPhone is incredibly sweet. Very fast indeed. In all honesty I think its the only way to make a decent speed game for it at the moment.

Pages: 1 ... 73 74 [75]