PDA

View Full Version : Star needs to wrap around stage


Poetress
08-26-2009, 12:16 PM
Okay, here's my problem: I've this project and I'm down to the very end but I can't figure it out. I've done quite extensive searching on-line but have came up with nothing, the books I have, have nothing in them to help so this is my last resort. The project has this star that goes across the stage, the movement I got, but it's suppose to wrap around or at least look as such, and repeat it's path...I can't figure out how to make this work...maybe I'm not asking the right questions, but hopefully someone will be able to help. :confused:

PS. It's all via ActionScript 3.0

sam.uk.net
08-26-2009, 03:34 PM
Hi!


so this is my last resort.


as.org is a last resort? Waaaa :o

For your star thing...all you need is to detect when the star is off the stage (if its x is more than the width of the stage or its y is more than the hieght of the stage ). When the star is off the stage, set the stars x and y to whatever values you like.

Assuming the star movieclip has can be accessed using "star" use the following code:


addEventListener(Event.ENTER_FRAME,checkBounds);

function checkBounds(evt:Event):void{
if(star.x>stage.stageWidth || star.y>=stage.stageHeight || star.y<0){
//star has gone offscreen
//change position of star (to whatever you want)
star.x=0;
star.y=0;

}
}


Hope that helps and sorry if I'm not too clear :eek:

sam.uk.net