dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: URGENT! Randomly placing objects on Screen.

  1. #1
    Junior Member
    Join Date
    Aug 2004
    Posts
    29

    URGENT! Randomly placing objects on Screen.

    Hey, I've got to finish a game before 12am today for Clock Day 2004! I forgot about it, being busy with 5 games and 2 animations. I know alot of action-script, unfortunately, I don't know about randomizing. So here's what i'm doing. I've got a game where the character is viewed from the top, and you haveto run around and collect an object, lets say, coins. I need to make it so the coins come and go randomly. Hope someone can help me, I've been searching on how to do this for ages. Thanks for reading this
    ------------------------------Tobunshi--------------------------------

  2. #2
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    Maybe something like this.... Create a coin movieclip and give it this code.....

    code:

    onClipEvent (load) {
    with (_root) {
    movieWidth = 550;
    movieHeight = 400;
    delay = true;
    lastTime = 0;
    wait = 3;
    }
    }
    onClipEvent (enterFrame) {
    with (_root) {
    if (delay) {
    if (Math.floor(getTimer()/1000) == lastTime+1) {
    delay = false;
    }
    } else if (Math.floor(getTimer()/1000) == lastTime+wait) {
    lastTime = Math.floor(getTimer()/1000);
    delay = true;
    _x = Math.random()*movieWidth;
    _y = Math.random()*movieHeight;
    }
    }
    }




    Hope it helps
    NTD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center