示例#1
0
 public Fireball(Texture2D[] textures, Vector2 position, Vector2 direction, FireballConfig config = null)
     : this(position, direction, config)
 {
     Random = new Random((int) (textures.GetHashCode() + position.GetHashCode() + direction.GetHashCode() + DateTime.Now.Ticks));
     _one = new Emitter(textures);
     _two = new Emitter(textures);
     _three = new Emitter(textures);
     _smokeOne = new Emitter(textures);
     _smokeTwo = new Emitter(textures);
 }
        protected override bool GenerateTexture(ref IntPtr texture_handle, byte* source, LibRocketNet.Vector2i source_dimensions)
        {
            var tex = new Texture2D(GraphicsDevice, source_dimensions.X, source_dimensions.Y, false, SurfaceFormat.Color);
            int length = 4 * (int)source_dimensions.X * (int)source_dimensions.Y;
            var data = new byte[length];

            //MemCopy((IntPtr)source, data, length);
            Marshal.Copy((IntPtr)source, data, 0, length);

            tex.SetData(data);

            texture_handle = (IntPtr)tex.GetHashCode();
            _textures[texture_handle] = tex;
            tex.Tag = LibRocketTextureTag;

            return true;
        }
    private static IntPtr CreateTexture(
		IntPtr bytes,
		int width,
		int height
	)
    {
        texture = new Texture2D(
            GraphicsDevice,
            width,
            height,
            false,
            SurfaceFormat.Color
        );
        byte[] pixels = new byte[width * height * 4];
        Marshal.Copy(bytes, pixels, 0, pixels.Length);
        texture.SetData(pixels);
        return new IntPtr(texture.GetHashCode());
    }