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


Similar Posts:


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

Actionscript 3 :: Movieclip Stops Rotating After It's Box2D Body

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

Flash 10 :: New 3D Tool For Rotating Around Objects?

Jun 21, 2010

Whats the 3d capability in flash cs5, I've been told there is a new 3d tool for rotating around objects. Does that mean an obj import is possible? I am eventually aiming for a series of gear wheels, one facing the screen rotating on its z axis. Is this possible.

View 0 Replies

Flash :: Moving And Rotating Objects Along A Sine Wave?

May 27, 2011

There are a couple of problems i'm having with this - the first is how to work out how to find where the tip of each sine curve is (ie the frequency) and the second is to work out how to rotate each object so that it slides sideways along the sine wave(note file is 800 x 600)here's my code: CarouselTest.as:

package
{
import com.greensock.easing.Sine;

[code].....

View 1 Replies

Classic Tweens Not Rotating Objects

Jul 25, 2011

So I just started using Flash CS4 from Flash 8, and I like it so far, but there's on major problem: the "classic tweens" (motion tweens) aren't rotating some of the objects I have. Like there's this flame thrower I drew, and I rotate it at the end of the motion tween, but it doesn't rotate. It will just wait till the last frame and then it will show the rotated frame. Motion works in the motion tweens, but not enlarging or rotating... why? It seems more like a glitch, because sometimes I make a classic tween and it rotates stuff just fine, but sometimes it just doesn't... what am I doing wrong here? What's going on?

View 3 Replies

ActionScript 3.0 :: Reassigning Z Value To Rotating Objects?

Feb 21, 2009

I need to reassign z value to some objects that are rotating in 3d. (see attachment).

This is my code: but it doesn't work:

ActionScript Code:
for (var i:uint=0; i<container.numChildren; i++) {
cont[i]=container.getChildAt(i)
//cont[i].z=cont[i].transform.getRelativeMatrix3D(root).position.z;

[Code].....

View 6 Replies

IDE :: Dragging Objects - Rotating And Easing

Aug 22, 2009

I have two drag-related questions. The first one is how to rotate an object by clicking and holding on it, then moving the mouse round in circles. Think of a clock face, and the user clicking and holding on one of the hands, then spinning it around. The centre point would be the part of the hand that's attached to the middle of the clock face, and the other end of the hand would be able to rotate 360 degrees around the face.

The second one (and not related to the first one, a separate query altogether) is how to drag something horizontally along the screen, but have it stuck at a certain speed. So if the user tries to quickly drag the clip from left to right, it will not reach the right instantly, but instead follow the cursor at a slow speed.

View 1 Replies

ActionScript 3.0 :: Understanding Script For Rotating Objects

Aug 13, 2009

I am trying to understand what part of AS3 script says loop through(create a continues 360 loop of objects) the images from an XML file, does this make any sense.[code]is this the part that says loop the images/objects.this is a little more to the script including the above to maybe understand better?[code]

View 40 Replies

ActionScript 3.0 :: Rotating Objects To Face Center?

Dec 14, 2009

All I need to do is rotate an object (which could spawn at any point along each of the four edges of the screen) so that it faces towards the centre of the screen. Obviously this will be done using the .rotationZ property. I will know the starting point of the object, and the centre point of the screen (400, 300). The object begins facing directly 'up' (e.g. if it spawned directly below the centre of the screen it would already be at the correct angle).

View 2 Replies

ActionScript 3.0 :: Setting Objects Width While Rotating?

Mar 24, 2010

I'm working on putting together a game at the moment which is similar in many ways to mini golf (or crazy golf, depending on where you come from). It is shown from a side-on view and to play the user must select the ball by holding the mouse down over it, then drag the mouse to indicate the direction they wish to fire the ball in. The distance they drag the mouse (this is capped obviously) determines the power of their shot.
 
I am currently using a triangular object with the tip placed at the centre of the ball to show to the user the direction they have chosen. This triangle rotates to face the position of the mouse, and I'm trying to get it to extend/shorten based on the distance from the mouse to the ball. I have code in place (below) that works when the mouse is either to the left or right of the ball, but behaves rather strangely when the mouse is above or below the ball. When the mouse is in either of the latter locations, the triangle extends to be far bigger than the maximum length allowed by the program, yet a trace shows it is still within acceptable limits! I'm almost beginning to think that Flash is switching the 'width' and 'length' attributes around when the object is rotated by either 90 or -90 degrees!
 
The code I am using is:

[Code]....
 
Here's a couple of screenshots of the game as it currently stands too - please don't laugh at the horrible placeholder art: none of it is final haha (also note that I haven't implemented 'gravity' yet, so everything is sort of hovering in mid-air.) The first image shows the code working as I want it to with the triangle at it's max width, the second shows the triangle going 'huge.'

View 6 Replies

ActionScript 3.0 :: Rotating Multiple Objects And Every Circle Around It

Nov 17, 2011

I have an idea of a game in my head and I wan't to get somekind of functional demo of it done in flash (CS3). I've looked everywhere but couldn't find tutorial for it, as I'm not sure what I'm looking for. I'm not that good in Actionscript. I'm now trying to describe this problem. On screen there's 4 rectangles, 2 in a row. So it's 2 rows with 2 rectangles in each. between all of them theres 4 circles. If I activate a rectangle with mouse and use arrow keys to rotate it smoothly 90 degrees, 2 nearest circles rotate with it. And same thing happens with all of the rectangles.

So I'm looking for somekind of solution where rotating an object also rotates every circle around it. and when circle rotates 90 degrees with rectangle as it's center point, it can be also rotated with another rectangle. I think I can't explain this clearly?

View 3 Replies

ActionScript 2.0 :: Rotating Multiple Objects On Same Path

Dec 24, 2002

There is an example of what I'm trying to do [URL]. The only difference is that I'd like to use several different objects in my file...and not only one (i.e., ball or whatever) - but different objects with different shapes, colors....circulating on the same "path".

View 1 Replies

ActionScript 2.0 :: Rotating Objects From Xml File - Modification

Oct 16, 2008

I've got on the web some code of nice rotating objects from xml file. But I need to make, that when you mouse over one object, the rotation get stopped. I don't know exactly how to do it, so I'm asking for your. Pasting bellow the code and URL example of the animation.

[Code]...

View 2 Replies

Flash8 HitTest Works Wierd With Rotating Objects?

Dec 29, 2009

How would i make hitTest work better with a rotating object(AS2). Becase i have a circle and it if gets near the rotating object (actually pretty far away) it starts the script,(new x and y)

I think thats the rotation script, becuase i took a break for like 4 days becuase it was irritating.

View 1 Replies

Actionscript 3.0 :: Dynamically Generated Objects Rotating Around Its Own Center?

May 12, 2009

i have a triangle that i generate using the following code:

Code: Select allinternal function generateTriangle(w, h, topPoint, color = "0xFF9900") {
var triangle:MovieClip = new MovieClip();
with (triangle.graphics) {

[Code]....

I use this function and a foreach loop to generate 9 differently colored and sized triangles, which works fine when i place them on the canvas. But if i try to rotate them they rotate around the 0,0 point - i want them to rotate around the center of the individual triangles, how do i do that?

1. How do i move a dynamically generated triangle inside a movieclip? Solved using [URL]

2. How do i access each of the triangles inside the movieclip, or even better, place them in 9 different movieclips using addChild so that i can move them around individually?

View 4 Replies

ActionScript 2.0 :: Rotating / Dragging Objects Based On Keypress

Jul 22, 2002

I have a bunch of draggable objects and I want to be able to rotate them. Is it best (possible?) to rotate them based on keypress or how might you go about this. Here is my keypress code so far ( draggin works - rotate doesn't )

[Code]...

View 5 Replies

ActionScript 3.0 :: Create A Rotating Planet - Add Buttons Or Other Interactive Objects?

Jul 26, 2010

I've created a sphere, and used a texture of Earth to create a rotating planet (using movie material). Is it possible to add buttons or other interactive objects to the material itself that will be clickable?Is there any other method for doing this (for example if I want something to happen when the user clicks on Australia...)

View 5 Replies

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

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

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

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 :: Use Fscommand2 Function, Flash Compiler Throwing An Error?

Jun 9, 2010

I am using Flash Professional CS5 with ActionScript 3.0. The problem is, When I am trying to use fscommand2 function, Flash Compiler throwing an error saying: Scene 1, Layer 'Layer 1', Frame 1, Line 7 1180: Call to a possibly undefined method fscommand2.But, I am able to use fscommand. But, it is for different purpose, so will not fulfill my requirement to get Device(Mobile) properties like DeviceID etc.

View 1 Replies

Flash - Realistic Dice Throwing Animation With Predefined Outcome

Jan 23, 2011

I need to create a small dice game in Flash. The random number generator is external and I have to create a 3D realistic dice animation with that outcome. I'm using Away3D engine and JigLib for physics. So far the best idea I've had is to do many simulations and create a list of outcomes and their corresponding input parameters (initial position, initial orientation and the forces added to the RigidBody). This is not working so well. Sometimes for the same parameters the outcome is different. What is the best way to do this?

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







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