Flash - Paddle Movement Using Box2D?

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


Similar Posts:


ActionScript 2.0 :: Ball Bouncing Off Paddle?

Nov 3, 2006

im was wondering if anyone knows the script for a ball bouncing off a paddle. I want the ball to bounce off the paddle in different directions depending on:

1) which side of the paddle it hits

2) which direction it came from

Ive only got this so far : script for the paddle

onClipEvent(enterFrame)
{
if (this.hitTest(_parent.ball)) //if this movieclip hits the movieclip 'ball'
tellTarget(_root.ball) //tell the ball to:[code]....

View 1 Replies

ActionScript 2.0 :: Paddle Won't Move In Pong Game?

May 3, 2005

I have attached my FLA & I was just wondering if anyone out there could tell me how to make it so that my paddle will move so that the pong game is playable.

View 4 Replies

ActionScript 2.0 :: Cant Get Ball To Bounce Off Of Paddle At Correct Angle

Apr 28, 2004

The game is like any other pong game with one differance. Rather then the paddle only moving left and right, it would move in a circle around the play field and you would not be able to rely on the walls to keep your ball in play. My problem is that I cant get the ball to bounce off of the paddle at the correct angle. Below is a link of the swf and fla that I have now.[code]

View 7 Replies

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

Flash :: Change Center Of Rotation Box2d?

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

Flash - Drawing Custom Polygons In Box2D?

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

Rotating And Throwing Objects Using Flash And Box2D 2.1a?

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

Flash - How To Climb Up Or Stick To Other Objects In Box2D

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

Flash :: Box2d Body Shape Modification?

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

ActionScript 2.0 :: Pong - Make The Ball Move And Bounce Around The Stage And Paddle

Oct 29, 2003

how to make the ball move and bounce around the stage. and i also need help on the paddle that the ball bounces off of.

View 11 Replies

Flash :: Box2d B2BodyDef Have A Massdata Property In Cocos2D?

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

Flash - Create A Platform Body That Spins On It's Center In Box2D?

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

Flash :: Box2d, Detect Collision Between Static And Dynamic Bodies?

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

Flash :: Preventing Box2d Player From Pressing Against Walls In Midair

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

Actionscript 3 :: Box2D In Flash Runs Quicker When Drawing Debug Data Than Not?

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

Flash :: Movie-style Shotgun Blast (sticky Collision) With Box2D?

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

Actionscript 3 :: Flash + Box2d Pool Game Breaks Online Because Shots Are Not Transmitted Precisely?

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

ActionScript 3.0 :: How To Use Box2d

Oct 18, 2010

how to use Box2d?

View 4 Replies

ActionScript 3.0 :: Box2D HelloWorld With No FLA?

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

Professional :: Box2D Not Working On IOS?

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

Box2D - How To Make Conveyor Belt

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

Box2D - How To Get Position Of Static Object

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

ActionScript 3.0 :: Box2D How To Display Graphics

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

ActionScript 3.0 :: Click Over An Object In Box2D?

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

ActionScript 2.0 :: Circular Movement To Linear Movement - Carousel To Conveyer Belt?

Jul 9, 2010

I've been playing with carousel code, and was wondering how to change it from circular animation (carousel) to left/right linear (conveyer belt) style animation, how to change the mover code and 't.angle = i * ((Math.PI*2)/numOfItems);'

[Code]....

View 1 Replies

Actionscript 3 :: How To Achieve A 1:1 Display Of Box2d Data

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

Actionscript 3 :: Box2d - How To Find Nearest Bodies

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

ActionScript 3.0 :: Box2D Collision Categories - How To Work

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

ActionScript 2.0 :: Flowing Mc Movement Opposite Of Mouse Movement

Feb 12, 2003

I have a mc (fStrip) which looks like a piece of filmstrip with thumbnail images in it. I want this mc to move when the users mouse is positioned over it, but I only want it to move only along it's x-axis and in a direction opposite that of the mouse. And I want it to move or flow smoothly.

I've been trying to figure this out (see my lame attempt below) but without much luck.

onClipEvent (mouseMove) {
buffer=20 //movement buffer
mousePos=_root.fStrip._xmouse //store mouse position
if (mymouse!=_root.fStrip._xmouse){ //if the mouse has moved

[Code].....

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved