game help needed

8 posts

Flag Post

what would the code be so that if the variable time = 120 then the movie clip mineral becomes visible (was invisible before),is randomly placed at the right side of the screen and moves towards the left at a constant speed. (also the code needs to go in the movieclip… i thoght it would look somthing like this:)
visible = false;
if (root.time == 120 then){
this.visible = true;
(i have no idea how to do random placement)
this. x
-=5 (i have no idea if this is right)

well ya i no that the code is wrong but any help is greatly appreciated.

 
Flag Post

so…Im guessing that your using the var time = 120 as like a counter and every frame you count from 0 to “time” (120) and then when it hits 120 your mc turns visible. in that case, you want to do this… (use [bracketopen]pre[bracketclose] for your code)

this code is if you wanted to create only 1 mc on your screen at once


var time = 120;
var i=0;
mineral.
visible = false;

mineral.onEnterFrame = function()
{
i++;
if(i < time)
{
this.visible = 1;
}
if(this.x > 0)
{
this._x -= 5;
}else{
this.
y = random(Stage.height/2)
50;
this.
x = Stage.width + 20;
}
}

Something like this will set mineral to invisible, then it will start going left 5 every frame until it hits 0. will its doing this, the mc should start getting more and more visible( i think thats what you want)

 
Flag Post

sweet thanks also for another game this is the code inside a movieclip

onClipEvent(load){
xDir=1;
yDir=1;
}
onClipEvent(enterFrame){
_x+=xDir;
_y+=yDir;
//random(3)-1 gives a number from -1 to 1
if (random(10) == 0){
xDir*=-1;
}
if (random(10) == 0){
yDir*=-1;
}
this.onRelease = function ()
{
for (x = 0; x < 8; x++)
{
_root.attachMovie("particle", "p_" + _root.parts, _root.getNextHighestDepth(), {_x: this._x, _y: this._y});
++_root.parts;
_root.score += 10;
removeMovieClip(bubble);
};
}
}

but when i click on it the movieclip (bubble) doesn’t disapper.

 
Flag Post

ok, well first, is the movieclip your in right now ie. “onClipEvent” the bubble mc or something else. If it is bubble, then just use this.removeMovieClip();, if not then you might want to try to use _root.bubble or _level0.bubble to remove it.

Another thing, on your:


if (random(10) == 0){
xDir*=-1;
}
if (random(10) == 0){
yDir*=-1;
}

since they are the same you should just add them together to take away space like this:

if (random(10) == 0){
xDir*=-1;
yDir*=-1;
}

 
Flag Post

that action script is in the bubble movie clip
EDIT: ok so i did those changes but it still doesn’t work. heres my code


onClipEvent(load){
xDir=1;
yDir=1;
}
onClipEvent(enterFrame){
_x+=xDir;
_y+=yDir;
//random(3)-1 gives a number from -1 to 1
if (random(10) == 0){
xDir*=-1;
yDir*=-1;
}
this.onRelease = function ()
{
for (x = 0; x < 8; x++)
{
root.attachMovie(“particle”, "p" + _root.parts, root.getNextHighestDepth(), {_x: this.x, y: this._y});
++
root.parts;
_root.score += 1.25;
this.removeMovieClip();
};
}
}

 
Flag Post

In your for loop. Alright, well you cannot use the removeMovieClip() function on a MC that is not created by the duplicateMovieClip(), createMovieClip(), attachMovie() ect. So either create the bubble mc with one of those functions or find another way to remove it, which im not really sure how to do.

 
Flag Post

hes right you cant just take it away entirely unless u add them like that, but if ur not afraid of wasting a tiny bit of memory, you could just hide it under something else, or off-screen.

 
Flag Post

If you last post was anything like this one, you deserved to be reported. Please don’t clog our forums with spam. We of course welcome thoughtful and helpful posts if you’d like to add something to the conversation.