ActionScript 3.0 :: Flash Box2D & 2D Shadows
Jul 24, 2011
I'm working on a AS3 Game Engine at the moment utilizing Box2D (2.1a) and 2D shadows. I have Box2D down but I've yet to find a way of drawing 2D shadows efficiently.I was following this tutorial only to be disappointed by the speed at which it rendered the Box2D shapes and the shadows.I was getting the vertices of the objects via this function:[code]And using it to draw the shadows via the AS3 graphics api.Can anyone recommend me a better more efficient way of programming 2D shadows?
View 2 Replies
Similar Posts:
Dec 28, 2010
Well, everything is in the title! I have an flash animation of a turning object, then I would like to add something under it that follows its movement, such as a dynamic shadow or a dynamic reflect.
View 1 Replies
Oct 10, 2006
Can you animate shadows with mcTween like all the other filters, or not? I'm guessing no because I didn't see it in the documentation, and i tried a few variations of what it might be.
View 5 Replies
Jan 3, 2011
I'm making a game like Arkanoid and to move the ship with mouse, I'm using the following code :
var mousex:int = costume.stage.mouseX;
if (mousex < paddleWidth/2)
mousex = paddleWidth/2;
else if (mousex > PhysiVals.STAGE_WIDTH - paddleWidth/2)
[code]....
Everything's going fine there! The paddle is moving the way it should! The problem is I want a little inclination towards the direction its moving and when it stops moving the angle of inclination should become zero.
View 1 Replies
Oct 18, 2005
How do they do this flip page effect and the gradient shadow behind?
[URL]
View 2 Replies
Feb 13, 2011
I have a b2PolygonShape body and apply a force to it.
_recbody->ApplyForce( b2Vec2(6.0, -6.0), _recbody->GetWorldCenter() );
I want to change the centre of rotation of the body to be more in the front of the body. So that applyForce and also collisions make the body not turn in the centre but more in the front.
View 2 Replies
Apr 14, 2011
I'm making a Flash game, and I've encountered a really weird problem while trying to draw a polygonal shape in Box2D.
Here's the code I use:
var fixtureDefs:Array = new Array();
...
var fDef:b2FixtureDef = new b2FixtureDef();
fDef.density = 0;
[code]....
Where vertexArray is a valid array containing 4 b2Vec2 vertices, making up a convex shape.The problem is, when I test, collisions don't work right for that body. Most other objects -enemies, user-controlled characters - pass straight through, as if the body isn't there at all. Some raycasts pass through as well.
Infuriatingly enough, one kind of bodies I have (a custom enemy) somehow does detect the body and collides with it. The raycasts that particular kind of enemy attempts do work - when your character hides behind the polygon, it's like they can't see him.The other weird thing: when I try the same code, only go for SetAsBox instead of SetAsArray, it works exactly as it should.I'm using a custom ContactListener class, but I haven't done any contact filtering (unless it's possible to do that without realising).I'm using the Flash 9 version of Box2D 2.1a.
View 2 Replies
Jul 26, 2011
i'm using flash with box2D 2.1a. i'm rotating ball hanging on the string. The path which the rotating ball trace is ellipse. When releasing the rotating ball from the string i want the ball to fly with the obtained direction, velocity and strength. As you can see in the pictures.[URL]..I've tried to do it with setPosition (method of b2Body) and with various joints. But I haven't got the needed results.
View 2 Replies
Jan 12, 2012
I know that trying to model character movement in Box2D is always hard/impossible, but I'm trying to see if there's any way to make an user-controlled object that cleanly slides against other objects, going up or down, that makes it look like the character is climbing/walking up or a down. The character could be modelled as a circle if that simplifies matters, but I don't see how I could get this effect using just a circle with a joint motor.
There's a "wheel joint" in the C++ version of Box2d, which I suppose I could port to Flash, but I don't know if that would give the correct effect either. Another idea I had was to have the character do little jumps, based on the normal of the object that it is touching. But I suspect that at corners, or at contacts with multiple objects, this will give weird results.
View 1 Replies
Jan 13, 2012
Is it possible to modify a shape within a body after assigning it, for example I have a box shape for my game hero body, and when I press the down arrow I want my hero to crouch witch means that I need the body shape to be resized.
I've already searched in google but it appears that the topic of modyfing shapes is not so popular. If it's impossible maybe you know a better way of doing this.
View 1 Replies
Mar 9, 2012
I want to know if box2d b2BodyDef has a massdata property or if it can be accessed in some way. I am not sure whether this can be done in Cocos2D but I have seen it in the flash code I am trying to re-implement in cocos2d.Here is the the code that brought about the question.
[Code]...
View 1 Replies
Feb 24, 2011
I'm trying to create spinning shapes floating in space. There is still gravity in the environment, however it should not affect these platform objects because they are static (right?). How can I apply a constant angularVelocity to it though? It doesn't seem to apply when I assign it a value, probably due because it's static.
The simplest example would be a spinning gear, an automated teeter-totter (not influenced by external forces). All I'm trying to make is a spinning rectangle that could interfere with a ball controlled by the user.Do I need to use Joints to pin it in place? How can I specify the details of not being influenced by the dynamic objects?
View 1 Replies
Apr 12, 2011
i am listening contact between dynamic bodies. But cannot listen contact between dynamic and static bodies .
I can handle collision detection on my b2contactListener class with this metod.
public override function BeginContact(contact:b2Contact):void {
// getting the fixtures that collided
var fixtureA:b2Fixture=contact.GetFixtureA();
[Code].....
View 1 Replies
Nov 20, 2011
I have setup a box2d world with a keyboard controlled player. The player can walk and jump. How do I prevent the player from "sticking" to walls while jumping and pressing the directional key towards an object?
View 3 Replies
Oct 21, 2010
I'm working on a tile based game, inspiredb by tutorials from the book "the essential guide to flash games". Please have a look at [URL] -- edit: by the way, the game idea is by no means mine, but i want to replicate the old game "sensitive" from the c64 [URL] for learning purposes I want to add shadows to all objects that stand in the water. However, since I want to keep my sprite count to a minimum, I have put all objects that don't do anything in a background bitmap. The best solution I can think of is to have:
1) a background bitmap (won't change during level)
2) a background shadows bitmap (won't change during level)
3) a sprite layer
4) and a sprite shadow layer at every screen, but this seems like a lot of work for just shadows.
View 5 Replies
Jan 24, 2010
I've created a small game with Box2d for AS3 - I have sprites attached to the stage that take their position from the underlying Box2d world. These sprites are mostly PNGs.When the game runs with DrawDebugData() bening called every update, it runs nice and smoothly. However when I comment this out, it runs choppily. In both cases all my sprites are being rendered. So it seems that it's running faster when it's drawing the debug data additionaly (i.e. my sprites are on the screen in both cases!)What's going on? Does drawing the debug data flick some sort of 'render quick' switch? If so, what's the switch!? I can't see it in the Box2D code.
function Update(e){
m_world.Step(m_timeStep, m_velocityIterations, m_positionIterations);
// draw debug?[code]...
Interestingly, If i set the debug draw scale to something different to my world scale, it slows down to 19fps. So there's something happening when it draws the boxes under my sprites causing it to run quicker..
View 2 Replies
Jan 29, 2011
I'm making a Flash game where the player throws balls of mud at objects in the sky. I'm using Box2D to model the physics. I don't want the ball to bounce off of objects (apply a normal force); instead I want it to impart its momentum on the object it is striking (like a movie-style shotgun blast).
View 1 Replies
Jun 8, 2011
Is there any way to turn off all special FX's and especially dropShadow's on all objects inside the application ?
View 2 Replies
Dec 25, 2010
I'm, working on this pool game: [URL] open it in TWO browser windows you will see that the 2 player modus starts. When you make a shot, every shot gets copied to the other player. Unfortunately it is not precise enough. The player makes the shot with this code:
[Code]..
View 2 Replies
Oct 18, 2010
how to use Box2d?
View 4 Replies
Aug 20, 2010
I recently did a quick demo on my site of Box2D (Box2DFlashAS3) with source code. Its basically just the HelloWorld example from the v2.1a distribution, but with a few tweaks. The most notable is that my version does not require a Flash FLA file to compile and run, its pure AS3. Simple and a good base to build on:
http:[url]........
View 3 Replies
Dec 17, 2011
Anyone know how to get BOX2D physics engine working on iOS? It seems to work on the adl tester but not when I actually test it on the device.
View 1 Replies
Mar 2, 2011
Here: Flash game
There is a flash game called garbage separator. In this game, there is a conveyor belt.
With 2 Circles you can move the conveyor and I think you can use boxes with joint for belt but i dont know how to give it the form:
Circular Form
How to do this with Box2d?
View 1 Replies
Apr 14, 2011
I'm using sensors in a Box2D project. On a collision with a sensor, I'd like to know the sensor's position in the world. I'm detecting the collision with a contact listener, but the sensor's position is always 0 0.
From my code: (edit, added the whole class)
public class MyContactListener extends b2ContactListener {
public var onSensorEvent:Function;
override public function BeginContact(contact:b2Contact):void {
if(contact.GetFixtureA().IsSensor()) {
var ud1:GameEntity = contact.GetFixtureA().GetBody().GetUserData();
[Code] .....
View 1 Replies
May 17, 2011
I have one question for your.This code I took from the site
ActionScript Code:
package {
import flash.display.Sprite;
[code]......
View 6 Replies
Nov 30, 2010
I need to click over an object in Box2D. Need to know which object i have clicked, and to delete that object. How could i know, which object i have clicked?..
View 1 Replies
Nov 7, 2010
Anyone know how to achieve a 1:1 display of box2d data?I'm dividing all my values by a Physics.Scale value (30) but boxes I create like this:polyDef.SetAsBox(640 /Physics. scale, 32 / Physics.scale);Are still showing up much larger than 640 pixels wide and 32 pixels high.Weirdly, my AABB for the world is showing up perfectly at 640x480.[code]
View 1 Replies
Feb 5, 2011
I am trying to detect bodies which are near current. To do it, I've created quite a big collision shape, around the current body, and made it sensor. Collision event was triggered, but it's not what I need. Main thing is that collision event is called only first time when another body entered the detection field... And I want to be able to detect changes in bodies location, after it. (I am considering the fact that other bodies are moving inside detection field)
View 1 Replies
Jan 13, 2011
I still have problem understanding how the collision category works. I'm only able to make it work by experimenting which is not good.
[Code]...
this works the way I wanted but only because I experimented around and found the right values (or at least values that work). I would prefer to know how the whole system works
View 6 Replies
Nov 30, 2011
I have made a Car Game using Box2D [in Flash] and I have one remaining bug, which I cannot fix. I added graphics and put them on top of the Box2D body. Everything went as good as expected, but after X rotations the movie clips for the car-wheels, stop spinning. I do something like this wheelSprite.rotation = wheelBody.GetAngle() * 180 / Math.PI. I ran a separate program and I saw that, if you do X.rotation += variable and you increase the variable every frame, after ~30 000 (value of variable) the MovieClip stops rotating, so I reset it to 0 after ~28 000. What do I do? The wheelBody.GetAngle()
View 2 Replies