Nu är jag inte någon super programerare men jag är logisk i mitt tanke sätt.
Jag skulle göra ett mc med 3 frames som hela tiden loopar och kollar vad
din variable score har för värde i frame 3, (se till att du har hela sökvägen till din variable score från _root) har den värde 10 så ska den göra något alltså en if sats
har den inte det så loopar den bara vidare till frame 1 osv. Detta mc lägger man seda ut på huvudlinjen så att det alltid finns med.
Hej,
Jag har detta actionscriptet i ett "catch"-spel. Vad jag inte kan få rätt på är hur jag ska göra för att skicka spelaren vidare vid vinst. Jag hade tänkt att man ska vinna när man fått 10 poäng (1p= en fångad boll)
Kan någon schysst actionscriptare hjälpa mig?
//this produces random balls that fall from the sky
depth = 0;
allBalls = new Array();
function makeNewClip() {
clearInterval(ranID);
ran = (Math.random()*4000)+1000;
ranID = setInterval(makeNewClip, ran);
newClip = _root.attachMovie('circle', 'circle'+depth, depth++);
allBalls.push(newClip);
//trace(allBalls);
newClip._x = Math.random()*Stage.width;
newClip._y = -50;
newClip.speed = (Math.random()*10)+5;
newClip.onEnterFrame = function() {
this._y += this.speed;
if (this._y>Stage.height) {
updateScore(-1);
for (i=0; i<allBalls.length; i++) {
if (this == allBalls*) {
allBalls.splice(i, 1);
//trace(allBalls)
}
}
this.removeMovieClip();
}
};
}
makeNewClip();
//
_root.attachMovie('slider', 'slider_mc', -1);
slider_mc._y = Stage.height-20;
maxSpeed=20;
xSpeed=0;
watchKeyboard = new Object();
watchKeyboard.onKeyDown = function() {
clearInterval(easeID);
if (Key.getCode() == Key.LEFT) {
if(xSpeed>-maxSpeed){
xSpeed--;
}
}
if (Key.getCode() == Key.RIGHT) {
if(xSpeed\<maxSpeed){
xSpeed++;
}
}
};
watchKeyboard.onKeyUp=function(){
clearInterval(easeID);
easeID=setInterval(ease,20);
}
Key.addListener(watchKeyboard);
slider_mc.onEnterFrame=function(){
this.\_x+=xSpeed;
}
function ease(){
if(xSpeed>0){
xSpeed--;
}
if(xSpeed<0){
xSpeed++;
}
if(xSpeed==0){
clearInterval(easeID);
}
}
//
_root.createEmptyMovieClip('watchCollision', -2);
watchCollision.onEnterFrame = function() {
for (i=0; i<allBalls.length; i++) {
if (allBalls*.hitTest(slider_mc)) {
//trace('we hit the slider');
allBalls*.removeMovieClip();
allBalls.splice(i, 1);
updateScore(1);
}
}
};
score = 0;
function updateScore(amount) {
score += amount;
score_txt.text = 'Fångade: '+score;
}
updateScore(0);
/The jimmo***