Fatty Owl
%Europe/Berlin %830 %2005, 20:55
Hier is mijn code, hij is redelijk lang maar er is een probleem. het onderste stukje over depth doet het niet. alleen als hij 2 traced werkt het, bij 1 niet.
var i = 0;
var speed = 0;
var maxspeed = 50;
var gas = undefined;
var fps = 12;
var tijd = 0;
var teller = 0;
var depthauto = this.auto_mc.getDepth();
this.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
gas = true;
} else if (Key.isDown(Key.LEFT)) {
gas = false;
} else {
gas = undefined;
}
if (gas == true) {
if (i<maxspeed) {
speed = i;
i += 0.2;
} else {
speed = maxspeed;
}
}
if (gas == false) {
if (i>0) {
speed = i;
i -= 0.4;
} else {
speed = 0;
}
}
if (gas == undefined) {
if (i>0) {
speed = i;
i -= 0.2;
} else {
speed = 0;
i = 0;
}
}
weg_mc._x -= speed;
muur2._x -= speed;
if (weg_mc._x<-600) {
weg_mc._x = 0;
}
if (weg_mc._x>0) {
weg_mc._x = -600;
}
if (speed>5) {
if (Key.isDown(Key.UP)) {
this.auto_mc._y -= 5;
this.auto_mc._x += 5;
}
if (Key.isDown(Key.DOWN)) {
this.auto_mc._y += 5;
this.auto_mc._x -= 5;
}
}
this.auto_mc.wiel_mc._rotation -= speed;
this.auto_mc.wiel2_mc._rotation -= speed;
if (auto_mc._y>115.5) {
auto_mc._y = 115.5;
auto_mc._x = 173.5;
}
if (auto_mc._y<0) {
auto_mc._y = 0;
auto_mc._x = 290.5;
}
teller += 1;
if (teller == fps) {
tijd += 1;
teller = 0;
}
if (tijd == 5) {
pos = random(2)+1;
if (pos == 1) {
trace("1");
xpos = 414.9;
ypos = 110.2;
depth = 1;
trace(depth);
} else if (pos == 2) {
trace("2");
xpos = 414.9;
ypos = 27.1;
depth = depthauto-1;
trace(depth);
}
this.muur2.removeMovieClip();
tijd = 0;
this.attachMovie("muur", "muur2", depth);
setProperty("muur2", _x, 0+xpos);
setProperty("muur2", _y, 0+ypos);
}
};
veel plezier.
var i = 0;
var speed = 0;
var maxspeed = 50;
var gas = undefined;
var fps = 12;
var tijd = 0;
var teller = 0;
var depthauto = this.auto_mc.getDepth();
this.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
gas = true;
} else if (Key.isDown(Key.LEFT)) {
gas = false;
} else {
gas = undefined;
}
if (gas == true) {
if (i<maxspeed) {
speed = i;
i += 0.2;
} else {
speed = maxspeed;
}
}
if (gas == false) {
if (i>0) {
speed = i;
i -= 0.4;
} else {
speed = 0;
}
}
if (gas == undefined) {
if (i>0) {
speed = i;
i -= 0.2;
} else {
speed = 0;
i = 0;
}
}
weg_mc._x -= speed;
muur2._x -= speed;
if (weg_mc._x<-600) {
weg_mc._x = 0;
}
if (weg_mc._x>0) {
weg_mc._x = -600;
}
if (speed>5) {
if (Key.isDown(Key.UP)) {
this.auto_mc._y -= 5;
this.auto_mc._x += 5;
}
if (Key.isDown(Key.DOWN)) {
this.auto_mc._y += 5;
this.auto_mc._x -= 5;
}
}
this.auto_mc.wiel_mc._rotation -= speed;
this.auto_mc.wiel2_mc._rotation -= speed;
if (auto_mc._y>115.5) {
auto_mc._y = 115.5;
auto_mc._x = 173.5;
}
if (auto_mc._y<0) {
auto_mc._y = 0;
auto_mc._x = 290.5;
}
teller += 1;
if (teller == fps) {
tijd += 1;
teller = 0;
}
if (tijd == 5) {
pos = random(2)+1;
if (pos == 1) {
trace("1");
xpos = 414.9;
ypos = 110.2;
depth = 1;
trace(depth);
} else if (pos == 2) {
trace("2");
xpos = 414.9;
ypos = 27.1;
depth = depthauto-1;
trace(depth);
}
this.muur2.removeMovieClip();
tijd = 0;
this.attachMovie("muur", "muur2", depth);
setProperty("muur2", _x, 0+xpos);
setProperty("muur2", _y, 0+ypos);
}
};
veel plezier.