-
1. Re: Applying physics to movieclip created with createEmptyMovieClip...
kglad Jun 14, 2009 8:13 AM (in response to Mulefish92)1 person found this helpfultry:
//force settings
//Drawing tools
_global.general = 0x0000FF;
//blue
_global.rubber = 0x9400D3;
//purule
_global.spring = 0x32CD32;
//green
_global.rope = 0x8B4513;
//brown
_global.explosion = 0xFFFF00;
//yellow
_global.explosion2 = 0xFFA500;
//orange
//tool setings
var thickness = 2;
_global.tool = general;
var alpha = 100;
//Scene colours
var land = 0x000000;
//black
var prop = 0x1D1D1D;
//charcoal (non-gravity affected prop)
var gprop = 0x696969;
//dim gray (gravity affected prop)
var backg = 0xD3D3D3;
//light gray
//Active objects
var main = 0xFF0000;
//red
var orange = 0xFF4500;
//orange
var a = 1;
var b = gen;
var menu = 0;
var d = 0;
LineA = new Array();
this.onLoad = function() {
for (a in LineA) {
LineA[a].power = 0.3;
LineA[a].yspeed = 0;
LineA[a].xspeed = 0;
LineA[a].friction = 0.95;
LineA[a].gravity = 0.1;
LineA[a].thrust = 0.75;
}
};
this.onEnterFrame = function() {
d++
for (a in LineA) {
LineA[a].xspeed *= friction;
LineA[a].yspeed += gravity;
LineA[a]._y += yspeed;
LineA[a]._x += xspeed;
}
};
onMouseDown = function () {
createEmptyMovieClip("Line", 1);
Line.lineStyle(thickness, tool, alpha);
// The function onMouseDown is activated when you click the mouse
button.
Line.moveTo(_xmouse, _ymouse);
// This moves the line to the starting point, which will be directly
where you
// clicked._xmouse and _ymouse are the x and y position of the mouse.
onMouseMove = function () { Line.lineTo(_xmouse, _ymouse);};
// This creates the line to the point where ever your mouse is dragged.
};
onMouseUp = function () {
onMouseMove = null;
lineA.push(Line);
}; -
2. Re: Applying physics to movieclip created with createEmptyMovieClip...
Mulefish92 Jun 15, 2009 3:43 AM (in response to kglad)Thanks Kglad, but now it only draws one line and has no gravity, ill spend some time on it tomorrow but can you see the problem?
Thanks in advance
-
3. Re: Applying physics to movieclip created with createEmptyMovieClip...
kglad Jun 15, 2009 6:43 AM (in response to Mulefish92)try:
//force settings
//Drawing tools
_global.general = 0x0000FF;
_global.rubber = 0x9400D3;
_global.spring = 0x32CD32;
_global.rope = 0x8B4513;
_global.explosion = 0xFFFF00;
_global.explosion2 = 0xFFA500;power = 0.3;
friction = 0.95;
gravity = 0.1;
thrust = 0.75;//tool setings
var thickness = 2;
_global.tool = general;
var alpha = 100;
//Scene colours
var land = 0x000000;
//black
var prop = 0x1D1D1D;
//charcoal (non-gravity affected prop)
var gprop = 0x696969;
//dim gray (gravity affected prop)
var backg = 0xD3D3D3;
//light gray
//Active objects
var main = 0xFF0000;
//red
var orange = 0xFF4500;
//orange
var a = 1;
var b = gen;
var menu = 0;
var dep = 0;
LineA = new Array();this.onEnterFrame = function() {
for (var i = 0; i<LineA.length; i++) {
LineA[i].xspeed *= friction;
LineA[i].yspeed += gravity;
LineA[i]._y += LineA[i].yspeed;
LineA[i]._x += LineA[i].xspeed;
}
};
onMouseDown = function () {
Line = createEmptyMovieClip("Line"+dep, dep++);
Line.lineStyle(thickness,tool,alpha);
Line.moveTo(_xmouse,_ymouse);
Line.xspeed = 0;
Line.yspeed = 0;
LineA.push(Line);
onMouseMove = function () {
Line.lineTo(_xmouse,_ymouse);
};
};
onMouseUp = function () {
onMouseMove = null;
};