/// <summary> /// This function draws or stamps one <code>FlxSprite</code> onto another. /// This function is NOT intended to replace <code>draw()</code>! /// </summary> /// <param name="brush">The image you want to use as a brush or stamp or pen or whatever.</param> /// <param name="x">The X coordinate of the brush's top left corner on this sprite.</param> /// <param name="y">They Y coordinate of the brush's top left corner on this sprite.</param> public void stamp(FlxSprite brush, int x = 0, int y = 0) { throw new NotImplementedException(); /* * Brush.drawFrame(); * var bitmapData:BitmapData = Brush.framePixels; * * //Simple draw * if(((Brush.angle == 0) || (Brush._bakedRotation > 0)) && (Brush.scale.x == 1) && (Brush.scale.y == 1) && (Brush.blend == null)) * { * _flashPoint.x = X; * _flashPoint.y = Y; * _flashRect2.width = bitmapData.width; * _flashRect2.height = bitmapData.height; * _pixels.copyPixels(bitmapData,_flashRect2,_flashPoint,null,null,true); * _flashRect2.width = _pixels.width; * _flashRect2.height = _pixels.height; * calcFrame(); * return; * } * * //Advanced draw * _matrix.identity(); * _matrix.translate(-Brush.origin.x,-Brush.origin.y); * _matrix.scale(Brush.scale.x,Brush.scale.y); * if(Brush.angle != 0) * _matrix.rotate(Brush.angle * 0.017453293); * _matrix.translate(X+Brush.origin.x,Y+Brush.origin.y); * _pixels.draw(bitmapData,_matrix,null,Brush.blend,null,Brush.antialiasing); * calcFrame(); */ }
public override void create() { base.create(); //FlxG.addCamera(new FlxCamera(50, 50, 500, 500)); //defaultLogo = new FlxSprite(FlxG.width / 2, FlxG.height / 2); ////defaultLogo.scaling = new FlxPoint(10, 10); //this.add(defaultLogo); //block = new FlxSprite(0, 0); //block.makeGraphic(100, 100, FlxColor.CYAN); //this.add(block); //block2 = new FlxSprite(100, 0); //block2.makeGraphic(100, 100, FlxColor.GREEN); //this.add(block2); //block3 = new FlxSprite(0, 100); //block3.makeGraphic(100, 100, FlxColor.INDIGO); //block3.drawLine(0, 0, 99, 99, FlxColor.BLACK, 1); //this.add(block3); //block4 = new FlxSprite(100, 100); //block4.makeGraphic(100, 100, FlxColor.PINK); //this.add(block4); background = new FlxSprite(0, 0, FlxS.ContentManager.Load<Texture2D>("bg")); this.add(background); megaman = new FlxSprite(50, 150); //megaman.loadGraphic(FlxS.ContentManager.Load<Texture2D>("megaman_run_test"), true, false, 49, 49); megaman.loadGraphic(FlxS.ContentManager.Load<Texture2D>("megaman_run"), true, false, 49, 49); megaman.addAnimation("run", new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }, 12); megaman.play("run", true); this.add(megaman); //FlxG.playMusic(FlxS.ContentManager.Load<SoundEffect>("applause")); //FlxG.play(FlxS.ContentManager.Load<SoundEffect>("background")); // change content processor to soundeffect //DoFlash(); DoQuake(); }
/// <summary> /// Clean up memory. /// </summary> public override void destroy() { screen.destroy(); screen = null; Target = null; Scroll = null; Deadzone = null; Bounds = null; Buffer = null; //_flashBitmap = null; //_flashRect = null; //_flashPoint = null; fxFlashComplete = null; fxFadeComplete = null; fxShakeComplete = null; fxShakeOffset = null; //_fill = null; base.destroy(); }
/// <summary> /// This function draws or stamps one <code>FlxSprite</code> onto another. /// This function is NOT intended to replace <code>draw()</code>! /// </summary> /// <param name="brush">The image you want to use as a brush or stamp or pen or whatever.</param> /// <param name="x">The X coordinate of the brush's top left corner on this sprite.</param> /// <param name="y">They Y coordinate of the brush's top left corner on this sprite.</param> public void stamp(FlxSprite brush, int x = 0, int y = 0) { throw new NotImplementedException(); /* Brush.drawFrame(); var bitmapData:BitmapData = Brush.framePixels; //Simple draw if(((Brush.angle == 0) || (Brush._bakedRotation > 0)) && (Brush.scale.x == 1) && (Brush.scale.y == 1) && (Brush.blend == null)) { _flashPoint.x = X; _flashPoint.y = Y; _flashRect2.width = bitmapData.width; _flashRect2.height = bitmapData.height; _pixels.copyPixels(bitmapData,_flashRect2,_flashPoint,null,null,true); _flashRect2.width = _pixels.width; _flashRect2.height = _pixels.height; calcFrame(); return; } //Advanced draw _matrix.identity(); _matrix.translate(-Brush.origin.x,-Brush.origin.y); _matrix.scale(Brush.scale.x,Brush.scale.y); if(Brush.angle != 0) _matrix.rotate(Brush.angle * 0.017453293); _matrix.translate(X+Brush.origin.x,Y+Brush.origin.y); _pixels.draw(bitmapData,_matrix,null,Brush.blend,null,Brush.antialiasing); calcFrame(); */ }
/// <summary> /// Instantiates a new camera at the specified location, with the specified size and zoom level. /// </summary> /// <param name="x">X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.</param> /// <param name="y">Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.</param> /// <param name="width">The width of the camera display in pixels.</param> /// <param name="height">The height of the camera display in pixels.</param> /// <param name="zoom">The initial zoom level of the camera. A zoom level of 2 will make all pixels display at 2x resolution.</param> public FlxCamera(float x, float y, int width, int height, float zoom = 0) : base() { X = x; Y = y; Width = width; Height = height; Target = null; Deadzone = null; Scroll = new FlxPoint(); _point = new FlxPoint(); Bounds = null; screen = new FlxSprite(); screen.makeGraphic((uint)width, (uint)height, new Color(0, 0, 0, 0)); screen.setOriginToCorner(); //Buffer = screen.Pixels; BgColor = FlxG.bgColor; _color = Color.White; //_color = 0xffffffff; /* * _flashBitmap = new Bitmap(buffer); * _flashBitmap.x = -width*0.5; * _flashBitmap.y = -height*0.5; * _flashSprite = new Sprite(); */ // flx# - ? // zoom = Zoom; //sets the scale of flash sprite, which in turn loads flashoffset values /* * _flashOffsetX = width*0.5*zoom; * _flashOffsetY = height*0.5*zoom; * _flashSprite.x = x + _flashOffsetX; * _flashSprite.y = y + _flashOffsetY; * _flashSprite.addChild(_flashBitmap); * _flashRect = new Rectangle(0,0,width,height); * _flashPoint = new Point(); */ fxFlashColor = Color.Black; fxFlashDuration = 0.0f; fxFlashComplete = null; fxFlashAlpha = 0.0f; fxFadeColor = Color.Black; fxFadeDuration = 0.0f; fxFadeComplete = null; fxFadeAlpha = 0.0f; fxShakeIntensity = 0.0f; fxShakeDuration = 0.0f; fxShakeComplete = null; fxShakeOffset = new FlxPoint(); fxShakeDirection = 0; //_fill = new BitmapData(width,height,true,0); // flx# //DefaultZoom = 1.0f; rotating = 0.0f; Zoom = zoom; FlashSprite = new FlxObject(); //BgColor = Color.Black; _fxHelperTexture = new Texture2D(FlxS.GraphicsDevice, 1, 1, false, SurfaceFormat.Color); _fxHelperTexture.SetData(new[] { Color.White }); _fillTexture = new Texture2D(FlxS.GraphicsDevice, 1, 1, false, SurfaceFormat.Color); _fillTexture.SetData(new[] { Color.White }); UpdateHelpers(); }
/// <summary> /// Instantiates a new camera at the specified location, with the specified size and zoom level. /// </summary> /// <param name="x">X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.</param> /// <param name="y">Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.</param> /// <param name="width">The width of the camera display in pixels.</param> /// <param name="height">The height of the camera display in pixels.</param> /// <param name="zoom">The initial zoom level of the camera. A zoom level of 2 will make all pixels display at 2x resolution.</param> public FlxCamera(float x, float y, int width, int height, float zoom = 0) : base() { X = x; Y = y; Width = width; Height = height; Target = null; Deadzone = null; Scroll = new FlxPoint(); _point = new FlxPoint(); Bounds = null; screen = new FlxSprite(); screen.makeGraphic((uint) width, (uint) height, new Color(0, 0, 0, 0)); screen.setOriginToCorner(); //Buffer = screen.Pixels; BgColor = FlxG.bgColor; _color = Color.White; //_color = 0xffffffff; /* _flashBitmap = new Bitmap(buffer); _flashBitmap.x = -width*0.5; _flashBitmap.y = -height*0.5; _flashSprite = new Sprite(); */ // flx# - ? // zoom = Zoom; //sets the scale of flash sprite, which in turn loads flashoffset values /* _flashOffsetX = width*0.5*zoom; _flashOffsetY = height*0.5*zoom; _flashSprite.x = x + _flashOffsetX; _flashSprite.y = y + _flashOffsetY; _flashSprite.addChild(_flashBitmap); _flashRect = new Rectangle(0,0,width,height); _flashPoint = new Point(); */ fxFlashColor = Color.Black; fxFlashDuration = 0.0f; fxFlashComplete = null; fxFlashAlpha = 0.0f; fxFadeColor = Color.Black; fxFadeDuration = 0.0f; fxFadeComplete = null; fxFadeAlpha = 0.0f; fxShakeIntensity = 0.0f; fxShakeDuration = 0.0f; fxShakeComplete = null; fxShakeOffset = new FlxPoint(); fxShakeDirection = 0; //_fill = new BitmapData(width,height,true,0); // flx# //DefaultZoom = 1.0f; rotating = 0.0f; Zoom = zoom; FlashSprite = new FlxObject(); //BgColor = Color.Black; _fxHelperTexture = new Texture2D(FlxS.GraphicsDevice, 1, 1, false, SurfaceFormat.Color); _fxHelperTexture.SetData(new[] { Color.White }); _fillTexture = new Texture2D(FlxS.GraphicsDevice, 1, 1, false, SurfaceFormat.Color); _fillTexture.SetData(new[] { Color.White }); UpdateHelpers(); }