Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all 6664 articles
Browse latest View live

Cant Open Pipeline Tool

$
0
0

@HurricanKai wrote:

no idea if this Belongs here, if not please move it!

So im revisiting some old Projects from XNA 3.1
I ported one to monogame 3.6 (which i just installed)
at least VS doesnt shows me errors, but now, i need to put the needed files into the pipeline to use them in my Project!
but if i start the Pipeline ... Nothing happens,
It shows up for 2 - 3 seconds in the Task Manager, But thats all
0 at all the stats in taskmanager

Thanks already for Helping

(I use Windows 10, Monogame 3.6, and Visual Studio 2017)

Posts: 9

Participants: 4

Read full topic


Need help,3D Collisions in monogame how it works?

Sound CreateIndex

$
0
0

@MuntyScruntFundle wrote:

According to the examples I've found, "CreateIndex" should give me access to more sound options than the simple SoundEffect.

I should have .IsLooped. I should have .Stop! No stop! So this class must have changed a fair bit.

Does anyone have any examples of how to setup a looped sound effect with the current framework? This isn't a song, it's an effect.

Thanks.

Posts: 4

Participants: 2

Read full topic

CallbackOnCollectedDelegate when draving

$
0
0

@Vodacek wrote:

Hi I am having some trouble with running my game. After year I have updated MonoGame to latest develop version. When in my game I look at specific location (I am using frustrum culling) I got this error:

CallbackOnCollectedDelegate occurred
Message: Managed Debugging Assistant 'CallbackOnCollectedDelegate' has detected a problem in 'xyz'.
Additional information: MonoGame.Framework!OpenGL.GL+DebugMessageCallbackProc::Invoke

in Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformDrawIndexedPrimitives(PrimitiveType primitiveType, Int32 baseVertex, Int32 startIndex, Int32 primitiveCount) in \MonoGame\MonoGame.Framework\Graphics\GraphicsDevice.OpenGL.cs:line1021

I am using DesktopGL on Windows 10 machine. Anyone experiencing same issue?

Posts: 1

Participants: 1

Read full topic

Simple Top Down shooter

$
0
0

@Jeremi247 wrote:

Hello.
I would like to share the game that I am developing just for the learning purposes.

It is a simple top-down shooter where your's targets are a little green enemies coming from the borders of the screen. I want to add some more opponents in the future but as for now they are the only ones.
There is no main objective in this game, but each kill is rewarded by some points added to the score and a little higher score multiplayer.

As for now there are two abilities that player can collect and use for his advantage. One of them is alternative weapon, and other one is a blast pulse, allowing player to clear whole map when situation is getting worse.

Game is always launching in 1280x720 window. But why? Simply put: I am a beginner, and unfortunately I forgot about asset scaling based on resolution, and it was too late when I remembered about that.

Download link for the curious ones: https://drive.google.com/open?id=0B31KVN8QjZ58WWVUNEk4T2xvX1k

CONTROLS:
Move with WASD or arrows.
Shoot with LMB in direction of your cursor. You can hold the button but clicking allows for faster shooting.
Slow down with left Shift. Sometimes it's hard to catch the ability laying on the ground.
Access menu with Esc.
Pause and resume with Space.

And a couple of screenshots


Additionally!
Due to the fact that I am beginner on C# field I would be glad to hear any constructive criticism despite my code which you can find on https://github.com/Jeremi247/TopDown

Posts: 1

Participants: 1

Read full topic

Fading sound.`

$
0
0

@MuntyScruntFundle wrote:

Hi folks.

I'm working with the Monogame internal sound classes and have a need to fade a looping sound in and out. The sound may take a second to fade in from 0 to 1 and fade out would be about the same.

I know the 'best practice' would be; write a load of code to Play then increase the volume, then a load of code to fade and Stop.

But, is there any reason why I shouldn't just Play the loop at the start of the game and fade it in and out when I need it? That way I can avoid all the state checking code and starts and stops.

Yes, I know it's lazy, and I'll end up doing it properly in the end anyway. Just wondering how other people would approach it.

Cheers.

Posts: 1

Participants: 1

Read full topic

RenderTarget2D.Dispose() throwing System.InvalidOperationException

$
0
0

@Payet_Romain wrote:

Hi,

I got a strange exception sometime when I try to dispose a RenderTarget2D

it's happen about 1 in 30 times and I do not understand what is wrong here.

Project:

Windows/OpenGL/Monogame 3.5.1

Declaration:

_target = new RenderTarget2D(graphicsDevice, Width, Height,
     false, SurfaceFormat.Color, graphicsDevice.PresentationParameters.DepthStencilFormat,
     graphicsDevice.PresentationParameters.MultiSampleCount, RenderTargetUsage.PreserveContents);

Exception:

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

StackTrace:

System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   à System.Collections.Generic.Dictionary`2.KeyCollection.Enumerator.MoveNext()
   à Microsoft.Xna.Framework.Graphics.GraphicsDevice.PlatformDeleteRenderTarget(Texture renderTarget)
   à Microsoft.Xna.Framework.Graphics.RenderTarget2D.<Dispose>b__c()
   à Microsoft.Xna.Framework.Threading.BlockOnUIThread(Action action)
   à Microsoft.Xna.Framework.Graphics.RenderTarget2D.Dispose(Boolean disposing)
   à Microsoft.Xna.Framework.Graphics.GraphicsResource.Finalize()

The code that throws the exception is GraphicsDevice.OpenGL.cs (Monogame 3.5.1 Source):

    internal void PlatformDeleteRenderTarget(Texture renderTarget) {
        var color = 0;
        var depth = 0;
        var stencil = 0;
        var colorIsRenderbuffer = false;

        var renderTarget2D = renderTarget as RenderTarget2D;
        if (renderTarget2D != null) {
            color = renderTarget2D.glColorBuffer;
            depth = renderTarget2D.glDepthBuffer;
            stencil = renderTarget2D.glStencilBuffer;
            colorIsRenderbuffer = color != renderTarget2D.glTexture;
        }

        if (color != 0) {
            if (colorIsRenderbuffer) this.framebufferHelper.DeleteRenderbuffer(color);
            if (stencil != 0 && stencil != depth) this.framebufferHelper.DeleteRenderbuffer(stencil);
            if (depth != 0) this.framebufferHelper.DeleteRenderbuffer(depth);

            var bindingsToDelete = new List<RenderTargetBinding[]>();
            foreach (var bindings in this.glFramebuffers.Keys) {
                foreach (var binding in bindings) {
                    if (binding.RenderTarget == renderTarget) {
                        bindingsToDelete.Add(bindings);
                        break;
                    }
                }
            }

            foreach (var bindings in bindingsToDelete) {
                var fbo = 0;
                if (this.glFramebuffers.TryGetValue(bindings, out fbo)) {
                    this.framebufferHelper.DeleteFramebuffer(fbo);
                    this.glFramebuffers.Remove(bindings);
                }
                if (this.glResolveFramebuffers.TryGetValue(bindings, out fbo)) {
                    this.framebufferHelper.DeleteFramebuffer(fbo);
                    this.glResolveFramebuffers.Remove(bindings);
                }
            }
        }
    }

I am sure the RenderTarget is not use after Disposing, so... I don't understand why one of the foreach loops crash.

Posts: 7

Participants: 2

Read full topic

Framework for Linux is unlisted on nuget.org?

$
0
0

@nac0n wrote:

Hi,
I use Bodhi Linux and Jetbrains Rider to test out development with Monogame but i found out that doing so may prove more difficult now that i can't find the monogame framework with the built-in nuget-installer. How come the Linux framework on nuget.org is unlisted? I can't download it via the installer due to this and Rider does not support the console installer yet.

Linux framework link: https://www.nuget.org/packages/MonoGame.Framework.Linux/

Can anyone explain why the framework is unlisted? Can also anyone here give a tip for alternative path to reference the framework in my project? (Don't suggest changing IDE cause that is the last thing that i'll try after i've tried everything else :slight_smile: )

//Nacon

Posts: 1

Participants: 1

Read full topic


How to make movement loop in game update??

$
0
0

@Peon501 wrote:

I have list with coords to move
I loop list in update
and then I loop coords inside
but my game freezes and my object gets to destination at the end and unfreezes.

how to make movements like this in monogame ?

basicly Iam getting teleport, not movement

Posts: 3

Participants: 2

Read full topic

MeasureString and font scaling.

$
0
0

@MuntyScruntFundle wrote:

Hi folks.

I've been playing about with the GUI part of the game I'm working on. I have a Box class which basically draws a rectangle but has a load of properties to display information in the space, one of which is text.

If I use the MeasureString function on text displayed 1:1 it's fine, however if I display text at .5 size and multiply the MeasureString by the same variable the text moves right and down,

Has anyone else found this?

I can't see how my calculations can be wrong, all I'm doing is multiplying the measure result by the ratio then divide it by 2 to find the centre point. For testing I'm using a very standard Tahoma that's been 'spritefonted'.

I could spriteify loads of different sizes of font, but that seems wasteful.

Any ideas?
Thanks.

Posts: 2

Participants: 2

Read full topic

Brand new to this!

$
0
0

@EmilioR93 wrote:

I am trying to find tutorials on how to use the software. I have pipeline but do I need something else? I seen someone using some other software along with pipeline. I am using a mac.

Posts: 2

Participants: 2

Read full topic

DrawPrimitives And Multiple Primitive Types, Depth Bug

$
0
0

@LepidopterasRevenge wrote:

I'm struggling to find discussion on how DrawPrimitives is intended to be used, particularly in complex uses with varied primitive types and am running into what looks like some depth issues

In my engine I'm batching together all primitives of a particular type and then passing each batch to DrawPrimitives. So all my texture+lighting polys get to DrawPrimitives in one batch, and then all my coloured polys in a separate call, and then all my coloured lines, and so on for each combination of primitive properties I could be using

As it stands my engine is putting out the following

The lines are spatially above the textures but sometimes appear to be occluded, or even glitching like they're overlapping? The line flickering isn't the gif compression, it's like they're on the same plane but they're not

And I'm experiencing the same problem for polys too, not just lines

When the other circles grow larger, they are spatially closer to the camera than the purple circle which should be completely occluded

I've tried a lot of different settings, trying all combinations of DepthBufferEnable and DepthBufferWriteEnable to no effect, so my assumption has become that I've misunderstood the way DrawPrimitives works and it does no batching behind the scenes. Therefore the separate calls render in the order they're called. But I'm unsure how to proceed in choosing an alternative

If I have to order every primitive manually then wouldn't I also have to roll my own shader as well or I'll get errors when polys intersect using BasicEffect?
But that would make BasicEffect kinda useless unless you were using only one primitive type that isn't textured? On account of having to set effect.Texture before each DrawPrimitive call. And that doesn't sound right to me so I must be missing something? Is that Texture setting behaviour even ordinary?

This is my main render method where I'm mostly just messing around with settings atm

protected override void Draw(GameTime gameTime)
{
    GraphicsDevice.Clear(Color.DarkBlue);

    GraphicsDevice.RasterizerState = new RasterizerState()
    {
        FillMode = FillMode.Solid,
        //CullMode = CullMode.None
    };
    GraphicsDevice.BlendState = BlendState.AlphaBlend;
    //GraphicsDevice.DepthStencilState = new DepthStencilState()
    //{
    //    DepthBufferEnable = true,
    //    DepthBufferWriteEnable = true
    //    //DepthStencilState.Default;//new DepthStencilState()
    //};
    //Graphics.ApplyChanges();
    //{
    //    DepthBufferEnable = false,
    //    DepthBufferWriteEnable = false,
    //    CounterClockwiseStencilFunction = CompareFunction.Always,
    //    StencilFunction = CompareFunction.Always,
    //    StencilFail = StencilOperation.IncrementSaturation,
    //    StencilPass = StencilOperation.IncrementSaturation,
    //    CounterClockwiseStencilFail = StencilOperation.IncrementSaturation,
    //    CounterClockwiseStencilPass = StencilOperation.IncrementSaturation,
    //    ReferenceStencil = 0,
    //    StencilEnable = true,
    //    StencilMask = 0,
    //};

    Renderer.Render(Graphics.GraphicsDevice);

    base.Draw(gameTime);
}

And these are each snipped from where we render each primitive type batch
Polys that have texture, colour and normal properties

            if (PolyTexturesPositionColourNormalTexture != null)
            {
                effect.TextureEnabled = true;
                effect.LightingEnabled = true;
                effect.VertexColorEnabled = true;
                renderer.Indices = PolyIndicesPositionColourNormalTexture;
                renderer.SetVertexBuffer(PolyVerticesPositionColourNormalTexture);
                Nullable<TextureReference> currentTexture;

                currentTexture = PolyTexturesPositionColourNormalTexture[0];
                if (currentTexture.HasValue)
                    effect.Texture = currentTexture.Value.Texture;

                int currentOffset = 0;
                //renderer.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, PolyVerticesPositionColourNormalTexture.VertexCount, 0, PolyVerticesPositionColourNormalTexture.VertexCount / 3);
                for (int i = 1; i < PolyTexturesPositionColourNormalTexture.Length; i++)
                {
                    currentTexture = PolyTexturesPositionColourNormalTexture[i];
                    if (currentTexture.HasValue)
                    {
                        foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                        {
                            pass.Apply();
                            renderer.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, currentOffset, (i - currentOffset) / 3);
                        }

                        effect.Texture = currentTexture.Value.Texture;
                        currentOffset = i;
                    }
                }
            }

Polys with just colour

            if (PolyVerticesPositionColourCountSampled > 0)
            {
                effect.TextureEnabled = false;
                effect.LightingEnabled = false;
                effect.VertexColorEnabled = true;
                renderer.Indices = PolyIndicesPositionColour;
                renderer.SetVertexBuffer(PolyVerticesPositionColour);
                //renderer.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, PolyVerticesPositionColour.VertexCount, 0, PolyVerticesPositionColour.VertexCount / 3);
                foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    renderer.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, PolyVerticesPositionColourCountSampled / 3);
                }
            }

Lines with just colour

            if (LineVerticesPositionColourCountSampled > 0)
            {
                effect.TextureEnabled = false;
                effect.LightingEnabled = false;
                effect.VertexColorEnabled = true;
                renderer.Indices = LineIndicesPositionColour;
                renderer.SetVertexBuffer(LineVerticesPositionColour);
                //renderer.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, LineVerticesPositionColour.VertexCount, 0, LineVerticesPositionColour.VertexCount / 2);
                foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    renderer.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, LineVerticesPositionColourCountSampled / 2);
                }
            }

Is my use case roll-my-own-shader territory? Am I doing completely everything wrong? Is the problem elsewhere?
I'm not finding much material talking about using a lot of different primitive types in tandem so struggling to figure out the way forward. Thanks for any help

Posts: 1

Participants: 1

Read full topic

Android OpenTK version is greater than TargetFrameworkVersion?

$
0
0

@Robert_Harbison wrote:

So I am currently setting up my first project for monogame for both Android (v6.0) and IOS. I am using visual studio 2017 and eveything seams to run fine but I get this error.
Line Suppression State Warning: The $(TargetFrameworkVersion) for OpenTK-1.0.dll (v7.1) is greater than the $(TargetFrameworkVersion) for your project (v6.0). You need to increase the $(TargetFrameworkVersion) for your project.
How would I go about fixing this? Or am I not developing for the correct Android version?

Posts: 5

Participants: 2

Read full topic

Loading my Scrolling Background

$
0
0

@158O wrote:

Hello, I was attempting to run my Scrolling Background(s) in Monogame which I've just created, however there is no error in my code, except whenever I try to run my project I get this:

Microsoft.Xna.Framework.Content.ContentLoadException: 'The content file was not found.'

I've already placed my background images inside the content area of Monogame but I am not sure how to work around this.

Posts: 8

Participants: 2

Read full topic

GTA2.NET monogame 3.6 port vs2017


Camera.LookAt & Rectangle Borders

$
0
0

@Mr_Nice_Guy wrote:

Hello, i have made an Camera Manager which uses Monogame.Extended.Camera2D. Now i have made Rectangles as Borders for a few worlds between which you can jump on map by input. My code is working for my first map without problems, but when i jump to an other map i have problems with my code. My code has 3 areas. The first is changing the camera position and the border rectangle. The second is looking if my cursor is in the window and at the side of the window and moves then. And the last is correcting the movement back, if the camera moves out of the border rectangle. When i now jump to the rectangle of world1 then i can just move left and right but not up and down and the camera is at the wrong position. Deleting the code for top/bottom correction makes it work. I really cant find the bug, so i appreciate tips. The most confusing thing is that it works on the one map and on the other not so i think the bug is anywhere located at the camera.lookat method.

` public void View(int world)
{
if (world == 0)
{
World = new Rectangle(0, 0, 3750, 2250);
mCamera.LookAt(new Vector2(400, 240));
}
if (world == 1)
{
World = new Rectangle(3750, 0, 2500, 1150);
mCamera.LookAt(new Vector2(4300, 250));
}
if (world == 2)
{
World = new Rectangle(3750, 1115, 2500, 1135);
mCamera.LookAt(new Vector2(4150, 1355));
}
if (world == 3)
{
World = new Rectangle(0, 0, 3750, 2250);
mCamera.LookAt(new Vector2(3350, 2010));
}
if (world == 4)
{
World = new Rectangle(6250, 0, 1250, 1125);
mCamera.LookAt(new Vector2(6650, 240));
}
if (world == 5)
{
World = new Rectangle(6250, 1125, 1250, 1125);
mCamera.LookAt(new Vector2(6650, 1360));
}
if (world == 6)
{
World = new Rectangle(0, 0, 3750, 2250);
mCamera.LookAt(new Vector2(400, 1665));
}
if (world == 7)
{
World = new Rectangle(0, 0, 3750, 2250);
mCamera.LookAt(new Vector2(3060, 420));
}
}

    public void Update(InputManager input)
    {
        const float movementSpeed = 15;
        const float zoomSpeed = 0.1f;
        

        if (input.GetMousePosition().X > sWindow.ClientBounds.Width - 20 // check if cursor on side of window
            && input.GetMousePosition().X <=
            sGraphics.GraphicsDevice.Viewport.Width) // check if cursor in window 
        {
            mCamera.Move(new Vector2(movementSpeed, 0)); // move right
        }

        if (input.GetMousePosition().X < 20
            && input.GetMousePosition().X >= 0)
        {
            mCamera.Move(new Vector2(-movementSpeed, 0)); // move left
        }

        if (input.GetMousePosition().Y > sWindow.ClientBounds.Height - 20
            && input.GetMousePosition().Y <= sGraphics.GraphicsDevice.Viewport.Height)
        {
            mCamera.Move(new Vector2(0, movementSpeed)); // move down
        }

        if (input.GetMousePosition().Y < 20
            && input.GetMousePosition().Y > 0)
        {
            mCamera.Move(new Vector2(0, -movementSpeed)); // move up
        }

        if (input.GetMouseScroll() > 0 && sZoom < 5) // scroll in
        {
            mCamera.ZoomIn(zoomSpeed);
            sZoom++;
        }
        if (input.GetMouseScroll() < 0 && sZoom > -5) // scroll out
        {
            mCamera.ZoomOut(zoomSpeed);
            sZoom--;
        }

        if (!World.Contains(mCamera.BoundingRectangle.Top, 0)) // bug
        {
            mCamera.Move(new Vector2(0, World.Top - mCamera.BoundingRectangle.Top));
        }

        if (!World.Contains(0, mCamera.BoundingRectangle.Bottom)) // // bug
        {
            mCamera.Move(new Vector2(0, World.Bottom - mCamera.BoundingRectangle.Bottom));
        }

        if (!World.Contains(mCamera.BoundingRectangle.Right, 0))
        {
            mCamera.Move(new Vector2(World.Right - mCamera.BoundingRectangle.Right, 0));
        }

        if (!World.Contains(mCamera.BoundingRectangle.Left, 0)) // 
        {
            mCamera.Move(new Vector2(World.Left - mCamera.BoundingRectangle.Left, 0));
        }

`

Posts: 1

Participants: 1

Read full topic

Finding Tutorials

$
0
0

@EmilioR93 wrote:

Hello, everyone! I am new to this programming thing and was wondering if any of you guys on here can direct me to tutorials on how to build 2D Platformer shooter games wit MonoGames and Visual Studio. Also do you need to use both MG and VS to make a game? Thank you!

Posts: 1

Participants: 1

Read full topic

Cannot start a new SceneTransition in Nez

$
0
0

@ninguem26 wrote:

Hi,

I'm using Monogame 3.5 with Nez in my personal project. When I try to use the Core.startSceneTransition function I get the following message on screen:

I'm calling the function like this:
Core.startSceneTransition(new FadeTransition(() => new MyScene()));

My idea was to activate the transition when the player is on the edge of the scene. Am I forgetting something for the transition to work?

Posts: 1

Participants: 1

Read full topic

"Importer 'TiledMapImporter' had unexpected failure!"

$
0
0

@MonoMan wrote:

Just got MonoGame.extended downloaded and set up. When I try to run a small test project that includes a Tiled map it gives me the error: "Importer 'TiledMapImporter' had unexpected failure!" I've tried looking it up but without much luck. I have the tileset image also loaded into the project and the Content folder does have the MonoGame.extended .dll referenced, but still gives me the same error. Any help?

Posts: 4

Participants: 2

Read full topic

InvalidEnum on VertexBuffer Dispose on iOS

$
0
0

@henry_lisowski wrote:

Hey, I'm working on porting to iOS and I have a weird problem. I'm disposing a VertexBuffer during the draw loop, and I'm getting an InvalidEnum exception. This is the exception:

GL.GetError() returned InvalidEnum (Microsoft.Xna.Framework.Graphics.MonoGameGLException)
at Microsoft.Xna.Framework.Graphics.GraphicsExtensions.CheckGLError () [0x0002b] in <8f12f9e1612b4706b592532dafc00c25>:0
at Microsoft.Xna.Framework.Graphics.VertexBuffer.b__31_0 () [0x0000e] in <8f12f9e1612b4706b592532dafc00c25>:0
at Microsoft.Xna.Framework.Threading.BlockOnUIThread (System.Action action) [0x0001e] in <8f12f9e1612b4706b592532dafc00c25>:0
at Microsoft.Xna.Framework.Graphics.VertexBuffer.Dispose (System.Boolean disposing) [0x0000f] in <8f12f9e1612b4706b592532dafc00c25>:0
at Microsoft.Xna.Framework.Graphics.GraphicsResource.Dispose () [0x00001] in <8f12f9e1612b4706b592532dafc00c25>:0

This is on the most recent develop branch.

Any thoughts?

Posts: 1

Participants: 1

Read full topic

Viewing all 6664 articles
Browse latest View live




Latest Images