Flash devs got nightmares about platforming. We web devs got nightmares about IE taking over and our CSS not working..
Horrible, HORRIBLE nightmares.
Flash devs got nightmares about platforming. We web devs got nightmares about IE taking over and our CSS not working..
Horrible, HORRIBLE nightmares.
We need to eradicate the source!
that, my friends, is why i don't use hitTesting.
there are plenty of better ways to do things than just checking if 2 movie clips are overlapping.
@j_m: But hit-testing is the easiest way. A lazy programmer makes a good programmer! In... some ways.
Well, the theory is: If you're lazy, technically you'll want your code to be the shortest thing possible. So it'll be efficient too.
In practice: It never really works out like that.
I was originally planning to switch from regular hitTestPoint's to testing pixels on the level bitmap, since that would save me a lot of trouble. Never actually did though.
Nyubis has nightmares of falling through platforms.
I have a feeling construction workers have nightmares like that too.
That's JM falling from the top of his bunker bed.
OK, getting back on topic, Using a V-Cam in Flash games is fairly easy...Well...not really i guess, i had to tweek min alot to use in my game. Actually, mines based right off the V-Cam by brian heasey (i spelled it wrong) make a square moviclip, on the first frame paste this:
import flash.display.BitmapData;
_visible = false;
addProperty("_x2",get_x2,set_x2);
addProperty("_y2",get_y2,set_y2);
addProperty("_xscale2",get_xscale2,set_xscale2);
addProperty("_yscale2",get_yscale2,set_yscale2);
addProperty("_rotation2",get_rotation2,set_rotation2);
var oldScaleMode:String = stage.scaleMode;
stage.scaleMode = "exactFit";
var sW:Number = Stage.width;
var sH:Number = Stage.height;
stage.scaleMode = oldScaleMode;
var bounds_obj:Object = this.getBounds(this);
var camH:Number = Math.abs(bounds_obj.yMax-bounds_obj.yMin);
var camW:Number = Math.abs(bounds_obj.xMax-bounds_obj.xMin);
var rp = {x:this._x, y:this._y};
onEnterFrame = function ():Void {
camControl();
};
function camControl():Void {
rp.x = _x;
rp.y = _y;
var h:Number = camH*(_yscale*.01);
var w:Number = camW*(_xscale*.01);
var _scaleY:Number = sH/h;
var _scaleX:Number = sW/w;
_x2 = (w/2)*_scaleX;
_y2 = (h/2)*_scaleY;
_xscale2 = _scaleX*100;
_yscale2 = _scaleY*100;
_rotation2 = -_rotation;
_parent.filters = this.filters;
_parent.transform.colorTransform = this.transform.colorTransform;
}
this.onUnload = reset;
function reset():Void {
_parent._xscale = 100;
_parent._yscale = 100;
_parent._x = 0;
_parent._y = 0;
_parent._rotation = 0;
_parent._visible = true;
}
function set_x2(value:Number):Void {
var a = {x:rp.x, y:rp.y};
_parent.localToGlobal(a);
_parent._x += value-a.x;
}
function get_x2():Number {
var a = {x:rp.x, y:rp.y};
_parent.localToGlobal(a);
return a.x;
}
function set_y2(value:Number):Void {
var a = {x:rp.x, y:rp.y};
_parent.localToGlobal(a);
_parent._y += value-a.y;
}
function get_y2():Number {
var a = {x:rp.x, y:rp.y};
_parent.localToGlobal(a);
return a.y;
}
function get_xscale2():Number {
return _parent._xscale;
}
function set_xscale2(value:Number):Void {
setProperty2("_xscale",value);
}
function get_yscale2():Number {
return _parent._yscale;
}
function set_yscale2(value:Number):Void {
setProperty2("_yscale",value);
}
function get_rotation2():Number {
return parent.rotation;
}
function set_rotation2(value:Number):Void {
setProperty2("_rotation",value);
}
function setProperty2(prop:String, n:Number):Void {
var a = {x:rp.x, y:rp.y};
_parent.localToGlobal(a);
_parent[prop] = n;
var b = {x:rp.x, y:rp.y};
_parent.localToGlobal(b);
_parent._x -= b.x-a.x;
_parent._y -= b.y-a.y;
}
Then on the movie clip action paste this:
onClipEvent (enterFrame) {
_y += (_root.player._y-_y)/4;
_x += (_root.player._x-_x)/4;
}
replace "player" wiht the name of your main character, should be smooth enough.

You must log in to post.