Código:
me permita reiniciar la partida y jugar nuevamente.private function onDie(element:TubeElement) { Alert("G A M E O V E R\nTOTAL POINTS: " + points, null)
Encontre sabrosos tutoriales de OOP pero sinceramente acabo de dar el salto a intentar con clases y me estoy enrredando solo... Si he conseguido varios avances, pero cosa mas, cosa menos, al terminar la partida no tengo idea de como volver al punto de origen y controlar siquiera un _root.gotoAndStop(2);
Loco del bloqueo he intentado cargar incluso un clip con fscommand("quit"); pero tampoco resulta..
Aqui definitivamente no hay errores de script, sino "mala praxis..."
Agradeceria si tu tienes mas experiencia y puedes ayudar a cerrar el caso.
*Posteo para referencia la clase princial del juego y marcare el "fin" con ///// prácticamente al final
Código:
import org.sepy.Grid import org.sepy.Box import org.sepy.Tube import org.sepy.TubeElement import mx.utils.CollectionImpl import mx.utils.Iterator import mx.transitions.Tween import mx.transitions.easing.Regular class org.sepy.Game extends MovieClip { static public var instance:Game static public var ELEMENTS_TO_SHOW:Number = 5 static var GRID_DEPTH:Number = 1 static var PTS_DEPTH:Number = 2 static var GRID_X:Number = 50 static var GRID_Y:Number = 50 private var target:MovieClip private var grid:Grid private var current:Object private var future:CollectionImpl private var futureBox:MovieClip private var pointsMc:MovieClip private var _points:Number private var _enabled:Boolean function Game(scope:MovieClip) { target = scope grid = Grid(target.attachMovie("grid", "grid", Game.GRID_DEPTH, {parent:this})) grid._x = Game.GRID_X grid._y = Game.GRID_Y future = new CollectionImpl(); _points = 0 createCollection(); createFutureBox(); createIntro(); createPointsMovieClip(); enabled = false } private function createPointsMovieClip() { pointsMc = target.attachMovie("points_mc", "pointsMc", Game.PTS_DEPTH) pointsMc._x = Game.GRID_X pointsMc._y = Game.GRID_Y - pointsMc._height pointsMc.points = "PTS: " + points } public function BeginGame() { enabled = true points = 0 Start(); _global.setTimeout(startFlood, 2500, this) } private function createIntro() { Alert("PRESS PLAY TO START", BeginGame) } private function Alert(message:String, handler:Object) { target.intro_mc.removeMovieClip(); target.attachMovie("intro_mc", "intro_mc", target.getNextHighestDepth(), {game:this}) target.intro._x = Stage.width/2 - target.intro_mc._width/2 target.intro._y = Stage.height/2 - target.intro_mc._height/2 target.intro_mc.hidden_bg.useHandCursor = false target.intro_mc.hidden_bg.onPress = function(){} target.intro_mc.start_button.label.autoSize = "left" target.intro_mc.start_button.label.text = message target.intro_mc.start_button.bg._width = target.intro_mc.start_button.label.textWidth target.intro_mc.start_button.bg._height = target.intro_mc.start_button.label.textHeight target.intro_mc.start_button.handler = handler target.intro_mc.start_button.scope = this if(handler != null){ target.intro_mc.start_button.onRelease = function(){ this.handler.call(this.scope) this._parent.removeMovieClip() } } else { target.intro_mc.start_button.onRelease = function(){ this._parent.removeMovieClip() } } } private function startFlood(me:Game) { me.grid.GetFirst().PlayInt(1) } private function createCollection():Void { for(var a:Number = 0; a < Game.ELEMENTS_TO_SHOW; a++) { future.addItem(Tube.next()) } } private function Start():Void { next(true); } private function next(is_first:Boolean) { current = future.getItemAt(0) future.removeItem(current) future.addItem(Tube.next()) grid.CreateTempObject(current) updateFutureBox(); } private function createFutureBox() { var mc:MovieClip = target.createEmptyMovieClip("futureBox", 100) var mc_boxes:MovieClip = mc.createEmptyMovieClip("boxes", 1) var mc_mask:MovieClip = mc.createEmptyMovieClip("mask", 3) mc_boxes.index = 0 mc_boxes.elements = new Array(); mc._x = Game.GRID_X mc._y = grid._y + grid.height + 5 var b:MovieClip for(var a:Number = 0; a < Game.ELEMENTS_TO_SHOW; a++) { mc_boxes.index++ b = mc_boxes.attachMovie("box", "box_"+mc_boxes.index, mc_boxes.index) b._x = (mc_boxes.index-1)*(b._width-1) b.attachMovie(future.getItemAt(a).symbolName, "element", 1) b.Disable(); mc_boxes.elements.push(b) } b = mc.attachMovie("box", "box_blue", 2) b._alpha = 20 var c = new Color(b) c.setRGB(0x000066) mc_mask.beginFill(0x000000, 100) mc_mask.moveTo(0,0) mc_mask.lineTo(mc_boxes._width, 0) mc_mask.lineTo(mc_boxes._width, mc_boxes._height) mc_mask.lineTo(0, mc_boxes._height) mc_mask.lineTo(0,0) mc_mask.endFill() mc_boxes.setMask(mc_mask) mc.lineStyle(1, 0x000000, 100) mc.moveTo(-1,-1) mc.lineTo(mc_boxes._width, -1) mc.lineTo(mc_boxes._width, mc_boxes._height) mc.lineTo(-1, mc_boxes._height) mc.lineTo(-1, -1) futureBox = target.futureBox } private function updateFutureBox():Void { var b:MovieClip futureBox.boxes.index++ b = futureBox.boxes.attachMovie("box", "box_"+futureBox.boxes.index, futureBox.boxes.index) b._x = (futureBox.boxes.index-1)*(b._width-1) b.attachMovie(future.getItemAt(future.getLength()-1).symbolName, "element", 1) b.Disable(); futureBox.boxes.elements.push(b) var tw:Tween = new Tween(futureBox.boxes, "_x", Regular.easeOut, futureBox.boxes._x, -(futureBox.boxes.index-Game.ELEMENTS_TO_SHOW)*(Box.WIDTH-1), .3, true) tw.onMotionFinished = function(me:Tween) { me.obj.elements.shift().removeMovieClip() } } private function onBoxOver(obj:Box) { if(enabled) { var pt = obj.GetPoint() grid.MoveTempObject(obj) } } private function onBoxOut(obj:Box) { //obj.DestroyTempObject() } private function onBoxRelease(obj:Box) { if(enabled) { var element:TubeElement = grid.ApplyTubeElement(obj, grid.GetTempClass()) element.addListener(this) element.broadcastMessage("onAddPoints", 1) grid.DestroyTempObject() obj.Disable() next() } } private function onDie(element:TubeElement) { ///////////////////////////////////////////////////////////////////////////////////////////// // Esto imprime puntos en un mc y ahi muere todo Alert("G A M E O V E R\nTOTAL POINTS: " + points, null) enabled = false //true te permite seguir moviendo piezas pero con la partida terminada (no cuenta) //_root.attachMovie("SOS","SOS_mc",999999); // intento de matar con fscommand("quit"); y cerrar ventana // Los puntos no interesan, solo reiniciar la partida y controlar el N° de frame en _root } private function onAddPoints(value:Number) { points += value } static public function main():Void { Stage.scaleMode = "noscale" registerClass("org_sepy_Box", org.sepy.Box); registerClass("org_sepy_Tube", org.sepy.Tube); registerClass("org_sepy_TubeElement", org.sepy.TubeElement); Game.instance = new Game(_root); } public function set enabled(value:Boolean) { _enabled = value } public function get enabled():Boolean { return _enabled } public function get points():Number { return _points } public function set points(value:Number) { _points = value pointsMc.points = "PTS: " + _points }
Si alguien quiere ver de que se trata solo pedir el material y levantamos un zip
Gracias por tu interes