Weird delay coming from class code.
hey there,
i'm working on game sets of platforms come onto screen 1 after creating , infinite runner. i'm doing this, maybe not effective way hasn't cause greif until now, having 2 trigger movieclips far off stage left. when hit platform, first 1 supposed move next platform line , move left. second, placed beyond first, sends set of platforms off distance.
issue i'm running in is, second set of platforms spawns in should be, takes second move makes game impossible first platform slides out under you.
below code these 2 triggers. thank in advance.
code class spawns next set of platforms.
package {
import flash.display.*;
import flash.events.*;
public class platformreset extends movieclip{
public var prevx:number;
public var prevy:number;
//construct function
public function platformreset():void
{
addeventlistener(event.enter_frame, collision);
}
private function collision(e:event):void{
if(this.hittestobject(movieclip(root).platform1)){
movieclip(root).platform2.x = 3200;
movieclip(root).platform2.y = 300;
movieclip(root).platform2.x -= movieclip(root).worldspeed;
trace("platform2 spawn");
}
else {
prevx = movieclip(root).platform2.x;
prevy = movieclip(root).platform2.y;
}
if(this.hittestobject(movieclip(root).platform2)){
movieclip(root).platform1.x = 3200;
movieclip(root).platform1.y = 300;
movieclip(root).platform1.x -= movieclip(root).worldspeed;
trace("platform1 spawn");
}
else {
prevx = movieclip(root).platform1.x;
prevy = movieclip(root).platform1.y;
}
}
}
}
this class moves first.
package {
import flash.display.*;
import flash.events.*;
public class platform2ndtrigger extends movieclip{
public var prevx:number;
public var prevy:number;
//construct function
public function platform2ndtrigger():void
{
addeventlistener(event.enter_frame, collision);
}
private function collision(e:event):void{
if(this.hittestobject(movieclip(root).platform1)){
movieclip(root).platform1.x = 0;
movieclip(root).platform1.y = 1200;
//movieclip(root).platform1.stop();
movieclip(root).platform2.x -= movieclip(root).worldspeed;
trace("platform1 hit 2nd trigger , moved");
}
else {
//prevx = movieclip(root).platform1.x;
//prevy = movieclip(root).platform1.y;
}
if(this.hittestobject(movieclip(root).platform2)){
movieclip(root).platform2.x = 0;
movieclip(root).platform2.y = 1200;
//movieclip(root).platform2.stop();
movieclip(root).platform1.x -= movieclip(root).worldspeed;
trace("platform2 hit 2nd trigger , moved");
}
else {
//prevx = movieclip(root).platform2.x;
//prevy = movieclip(root).platform2.y;
}
}
}
}
wrapping things in classes bit odd aside.
what classes "platformreset" , "platform2ndtrigger" applied to? hittests referencing they're applied (e.g. this.hittestobject).
More discussions in ActionScript 3
adobe
Comments
Post a Comment