Menu
  • HOME
  • TAGS

XNA Game with MonoGame on Mac

osx,xna,monogame

I have solved this by adding the Tao.sdl.dll file to the project and adding in a .net reference for the project. Thanks for the help ...

When I pass a Texture2D as parameter to a class, this texture is null

c#,menu,xna,monogame

LoadContent is called by XNA after your MainMenuScreen is initialized. You may have to defer the usage of your playGame object to the moment when the texture is loaded or initialize your MenuEntries in the LoadContent.

Tile tearing with float positioning, MonoGame

monogame,subpixel

Try moving a camera instead of moving your tiles. The camera can move a floating point values, and your tiles will not have tearing because the are a fixed positions. Here's an example of how I render a tilemap in an old game of mine. I haven't posted every structure...

Xamarin using cross platform 3D engine

xamarin,xna,cross-platform,monogame

Monogame is an open source implementation of the XNA API. It uses the same classes and namespace than XNA but it is a new implementation that is cross-platform. It used to require the XNA framework for its content pipeline tool. But since version 3.3, Monogame provides its own tool so...

Monogame rotating a sprite

c#,monogame,image-rotation

Answer: in the new Vector2(x, y) I just had to set x and y values that are within the image.

SimplexNoise terrain in MonoGame

c#,monogame,procedural-generation,simplex-noise

Check line 133 in the SimplexNoise you are using: // The result is scaled to return values in the interval [-1,1]. After you divide it by 10, the result would be in range from -0.1 to +0.1 You need a range from 0 to 1, so instead of dividing by...

How to divide Vector2 to Vector2 Arrays?

c#,vector,xna-4.0,monogame

How about something like this: // For N waypoints between a start and end, we need N+1 segments segments = WaypointAmount + 1; xSeg = (end.x - start.x) / segments; ySeg = (end.y - start.y) / segments; // even though we have N+1 segments, adding the last segment would take...

MonoGame renderTarget2D Error

c#,runtime-error,monogame

The resolution of your RenderTarget2D may be the problem. I have noticed this needs to be a multiple of 4 when using SharpDX but I can't find any documentation to back this up. Try using 1280x720 rather than 1281x721....

Monogame sprite alpha blending

c#,monogame,alphablending,spritebatch

Try this: spriteBatch.Draw(Tex2D, TargetRec, new Color(Color.White) * weight[x,y]); This is the proper way to draw things transparently when SpriteBatch is using premultiplication. The alpha channel works differently when drawing with premultiplication. The basic change you need to make is to multiply the color by the transparency instead of setting the...

Create a big image out of several other small images in MonoGame

monogame

You can render different textures into one using RenderTarget2D _renderTarget = new RenderTarget2D(GraphicsDevice, (int)size.X, (int)size.Y); GraphicsDevice.SetRenderTarget(_renderTarget); GraphicsDevice.Clear(Color.Transparent); SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque); //draw some stuff. SpriteBatch.End() GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Clear(Color.Blue); SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque); SpriteBatch.Draw(_renderTarget, Vector2.Zero, Color.white);...

Rectangle's width increasing more than it should while trying to resize the rectangle

c#,tooltip,monogame

Fixed by adding: value.Replace("\n", "") in temp = parseText(value, Size.Width); I was doing that before the while loop, but not inside it. Therefore, the text was getting a bunch of new lines, and when it got called again, the new lines disappeared before the while loop. It should look like...

How to use Xna Content Compiler on visual studio 2013

c#,xna,visual-studio-2013,monogame

Another rather classic solution is to install XNA framework included in Windows Phone SDK 7, create a separate XNA solution just for the purpose of building XNB files. To get XNA working on your computer (for VS2010 - VS2013) first download Windows Phone SDK 7 and 8 (both of them)...

Function of base.Update and base.Draw in Monogame?

c#,xna,monogame

Accordingly to the source code of MonoGame linked by Dylan Wilson, the Update and Draw methods from the base class Game just called Update(...) and Draw(...) on a each element of a filtered GameComponentCollection, a Collection of IGameComponent. IGameComponent is an interface that show how XNA and Monogame want you...

Foreach statement does not contain public definition for getEnumerator

c#,collision,monogame,enumerator

The error is because paddle1 is of type Player, not an IEnumerable. If you only have two players, you shouldn't have to loop and can just implement your function like this: public void CollisionDetection(Player firstPlayer, Player secondPlayer) { firstPlayer.Update(gameTime); secondPlayer.Update(gameTime); if (firstPlayer.CollisionSprite(secondPlayer)) { firstPlayer.Velocity = -firstPlayer.Velocity; secondPlayer.Velocity = -secondPlayer.Velocity; }...

Ubuntu - MonoGame static graphics.Viewport size

ubuntu,graphics,monodevelop,viewport,monogame

So, I still don't know what was causing the problem, but I managed to avoid it. I was trying to get graphics.Viewport.Width graphics.Viewport.Height in a protected override void LoadContent() function. That's where the values were wrong. I tested some options and it came out that in the game class constructor,...

How do I can set a fixed play area in xaml monogame?

c#,xaml,windows-store-apps,monogame

You can set multiple render targets to draw to for your sprite batch. I would make your entire gameplay logic or area be drawn as or return a Texture2D at the desired size. Then in your Game1.cs or where ever, you position that texture accordingly in additional to the UI...

Create MonoGame.Framework.iOS.dll

ios,dll,monogame

You can find the latest built DLLs at: http://teamcity.monogame.net/viewType.html?buildTypeId=MonoGame_DevelopMac Just open the latest build and navigate to "Artifacts" tab....

drawString not drawing text on my game

monogame,drawstring,spritebatch

You should start by removing any other draw calls. If you can then see the string, it means that the string is being rendered behind something else. Then you need to play with layerDepth values (from 0.0 to 1.0 where 1.0 is the front)

Get android screen resolution

c#,android,monogame

[EDITED] try using this. import android.util.DisplayMetrics; DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int screen_width = metrics.widthPixels; int screen_height = metrics.heightPixels; float density = metrics.density; OR like this import android.util.DisplayMetrics; public class Resolution() { int screen_width; int screen_height; float density; public Resolution(Activity activity) { DisplayMetrics metrics = new DisplayMetrics();...

NuGet package contains assembly with the same name as an assembly in another package

visual-studio,visual-studio-2013,nuget,monogame,opentk

The MonoGame.Binaries NuGet package adds a reference to OpenTK.dll from its MonoGame.Binaries.targets that it adds to your project. This .targets file is in one of the packages\MonoGame.Binaries.3.2.0\build subdirectories depending on the project's target framework which in your case is net40. If you remove the following section from the MonoGame.Binaries.targets file...

How to save the response in a custom made popup dialog

c#,monogame

You can do this with Actions. In the PopupDialog class, add private Action<int> Callback; to the properties and this code to the constructor: public PopupDialog(Action<int> callback /*, rest of constructor parameters if any */) { /* Rest of constructor code, if any */ if (callback == null) throw new ArgumentNullException();...

Xamarin realease build lower size

c#,android,xamarin,monogame

So I made a new project and copied all the old files from the old project into the new, then I build the solution in "release" mode as I did before, I linked "SDK assemblies only" just like in the screenshot above, and then I debugged the project, and the...

Monogame “lighting” specific objects

c#,monogame,lighting

Basically, you have 2 options: Use a pixel shader to render the lighting sprite only on the desired area or Use the stencil buffer and render the pillar into it before you aplly the lighting sprite. I won't explain this in detail because both ways are explained extensively at this...

simple 2d collision in monogame (using xna pipeline)

c#,collision,detection,monogame

SOLVED: turns out that it was no the collision that was the problem, but what occured inside the if-statements :)

Xamarin Signed Release apk will install but not run

android,visual-studio-2013,xamarin,monogame

So it turns out this was nothing to do with the signing or building of the release mode apk, it was actually down to an exception which was only being thrown when the app was built in release mode (I have no idea why this was the case). The thing...

Monogame XNA transform matrix for a single object?

c#,matrix,xna,monogame

If you want to use a specific spritebatch begin call for some drawing calls only, you can start a new one as needed. for example SpriteBatch.Begin(...matrix); //Draw stuff with matrix SpriteBatch.End(); SpriteBatch.Begin(); //do the rest of the drawing SpriteBatch.End(); this is commonly used to draw a bunch of objects with...

Calling on existing classes? [closed]

c#,class,monogame

using System; namespace TestOfFunctions; { public class Game1 { private static int _someVariable = 15; public static int SomeVariable { get { return _someVariable; } set { _someVariable = value; } } } public class MainClass { public static void Main() { Console.WriteLine (Game1.SomeVariable); Game1.SomeVariable = 30; Console.WriteLine (Game1.SomeVariable); }...

How to check if Mouse is available in XNA - Monogame

c#,xna,mouse,monogame,win-universal-app

You have various solutions, depends of what you want to do : You can add a try-catch around this.IsMouseVisible. If you get a exception, you know for sure that the mouse is unavailable. You have conditional compilation symbols with XNA. Use #if !WINDOWS_PHONE to prevent phones to check the mouse....

Monogame audio not working

c#,audio,xna,monogame

Well, I found an answer! It appears VS2013 doesn't allow .wav files as songs, so I had to make it a soundeffect, or something like that (I still don't fully get it). It works now though, and I'll keep this post up for reference!

Monogame running very slow on Windows Phone

c#,windows-phone-8.1,windows-8.1,monogame

Thanks to thumbmunkeys, the problem is fixed. The debugger makes the game very slow, so not attaching the debugger brings the game back to 30fps. This can be tested by deploying the app using Visual Studio, then stopping the debugger and starting the game on the device....

How to convert 8bit sound to 16bit

c#,vb.net,bit-shift,monogame

Based on your code example, it appears that the only thing you have left remaining to do is to shift the 8-bit samples left 8 bits, so that the data occupies the most-significant-bits of the 16-bit sample. I.e.: Dim buffer((44100 * 2) - 1) As Byte ' place to dump...

XNA Framework / Monogame, creating 100 instances of object

c#,xna,monogame

Can you use a list? You may need to include this: using System.Collections.Generic; //Somewhere in the class List<Wheel> myWheels = new List<Wheel>(); // In your method var _wheel = new Wheel(); // Set your properties myWheels.Add(_wheel); //Then when needed, you can loop like this: foreach(var wheel in myWheels) { //...

2D Monogame: Rectangle collision detection, side specific

c#,xna,monogame

The Rectangle class in XNA has 4 properties that can be of use here: Left, Top, Right and Bottom. You can use these to determine which side(s) the collision took place from. For example, consider the Player.Rectangle.Left > Map.Rectangle.Left. If this is true, then the collision could have ocurred on...

Creating a Tooltip rectangle and checking when the rectangle leaves the screen

c#,monogame

Fixed the issue by taking a different approach. Instead of trying to reposition the rectangle to the opposite side of the mouse, I totally stop the rectangle from leaving the screen. When trying to set the Vector2 Position of the tooltip, it checks if it leaves the borders. Like this:...

Error message in Monogame: Unhandled Exception: System.DllNotFoundException: SDL2.dll

c#,mono,monodevelop,monogame

I don't think it's a duplicate because if you look closely at the error messages, they're different. The Tao.Sdl.dll.config file is present in the /bin/Debug folder. As suggested in http://www.mono-project.com/docs/advanced/pinvoke/dllnotfoundexception/ I typed MONO_LOG_LEVEL=debug mono /home/stefan/Downloads/LinuxMonoGameMovingTeddyBears/bin/Debug/MovingTeddyBears.exe and I got Mono: Assembly Loader probing location: '/usr/lib/mono/4.5/mscorlib.dll'. Mono: Image addref mscorlib[0x1620550] -> /usr/lib/mono/4.5/mscorlib.dll[0x161fad0]:...

How to know if a rectangle in xna is moving up or down

xna,chat,monogame

Keep the old position of mouse.Y in a variable then check if mouse.Y is less than the variable. If it is less than the variable then the scroll is moving upwards. Else it is moving down.

XNA/Monogame GraphicsDevice method change? What is proper way to instantiate it?

xna,monogame

Try this: GraphicsDevice newGraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, new PresentationParameters()); Texture2D texture = new Texture2D(newGraphicsDevice, 1, 1) Keep in mind that the width and height of the Texture2D must be > 0....

Monogame Content Pipeline has stopped working

c#,visual-studio-2013,xna-4.0,monogame,content-pipeline

In case you're still having this problem, or someone else finds the question (like I did trying to solve this a little while ago): for me, the problem was that my windows/system32 directory wasn't in my 'path' environment variable. That's where the setx.exe program resides, and the XNA content project...

Is sidescroller movement just offsetting the background?, MonoGame

movement,monogame,side-scroller

There are many ways of programming a sidescroller. I recommend you google around for examples before you begin coding you own. As you have suggested, one of the best (or atleast most common) ways of programming a side scroller is by storing an offset variable which is added to the...

C# Monogame & Farseer Physics: Collisions

c#,box2d,monogame,farseer

Unfortunately, this is surprisingly difficult to do with Box2D. The best I could manage when I tried, was to record the velocity of the ball when the contact started, and then when the contact ends, manually set the velocity to what I wanted. That works fine when the ball only...

Can’t Load .fbx from blender to Monogame correctly

c#,blender,monogame

Ok, I finally realized what the problem was... my drawing code was incorrect. I tried https://msdn.microsoft.com/en-us/library/bb197293(v=xnagamestudio.31).aspx code from msdn website and it all worked out. I am stupid. Also, downloading https://msxna.codeplex.com/releases/view/117230 and installing all the files in the correct order (following the instructions .txt) fixed the monogame content project error...

Draw Rectangle in MonoGame

c#,circle,monogame,rectangles,drawrectangle

EDIT You can learn basic things for MonoGame with tutorials I've put on GitHub : https://github.com/aybe/MonoGameSamples Use 3D primitives and a 2D projection Here's a simple example with explanations I define a 10x10 rectangle and set the world matrix to make it look like a 2D projection : Note :...

Is it possible to get “contextual” gestures in Monogame/XNA?

c#,gesture,multi-touch,monogame

That feature is not built in to MonoGame, as it is not part of original XNA. Essentially you'd want more than one 'logical' TouchPanel defined by its sub-rectangle of the window. However TouchPanel is static, hence there is only one for the whole game in default XNA. The good news...

SwapChainBackgroundPanel letterboxing Monogame Windows Store App

windows,xaml,windows-store-apps,monogame

After some researched I think I've figured it out thanks to this blog post. To those who are in a similar situation, here's what I did. The beauty of the solution is that the letterboxing is automatically managed by the Resolution class. All I have to do is update the...

Windows Phone 8 MonoGame projects stopped working

c#,windows-phone-8,monogame

Annoyed about what happen i spent a few hours tracking it down. I had MonoGame 3.0.1 installed. When i downloaded the 3.2 windows installation file some or all of the DLL's for the framework where throwing the errors. I did complete uninstall and re-installs but the 3.2 version never works....

Step through MonoGame source code

c#,visual-studio,visual-studio-2013,visual-studio-debugging,monogame

No. Visual Studio requires a successful compilation to enable stepping through code.

How to get display resolution (screen size)?

c#,xna,monogame

_ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width; _ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height; extra references: System.Drawing , System.Windows.Forms...

How to target the Windows Store from an existing Windows Application type of project

c#,.net,visual-studio,windows-store-apps,monogame

No, there isn't any direct retargeting. You'll need to create a new project and then copy code over. How difficult that will be will depend on the specific code. Windows Store apps use a limited set of the .Net Framework (see .NET for Windows Runtime apps). The bulk of the...

How to publish android app / open it on my mobile

c#,android,monogame

@Shiro If you have APK file (Android Package executable file) then you can directly copy it on your phone and install it.

Sub pixel movement need 1 transparent pixel on the edge to move smooth

monogame,subpixel

Texture border colors were created for precisely this sort of situation. The basic idea is that you can replace certain texel fetch operations (those outside the normalized range [0.0,1.0]) with a constant color. Border colors work for texture filtering too, which may implicitly fetch a neighbor texel outside the normalized...

Smooth slow pixel art movement MonoGame

c#,monogame

The thing i needed to to whas scale the images in PS and then draw them using linear

Generating a nebula cloud in circle [duplicate]

c#,windows,math,xna,monogame

The formula for a circle area is x^2 + y^2 <= r^2 Given a x you can calculate y like this y <= +/-sqrt( r^2 - x^2 ) By applying different scaling factors to the axis you can create an ellipse. Another possibility is to generate points in a rectangle...

Expression denotes a `type', where a `variable', `value' or `method group' was expected (CS0119) (MyFirstGame)

c#,monodevelop,monogame

Those two lines of code you indicated are missing the 'new' operator, which is required to instantiate the Vector2 (or any) class. ballSprite = new SpriteObject(texBall, new Vector2(200, 0), new Vector2(10.0f, 0.0f)); starSprite = new SpriteObject(texStar, Vector2.Zero, new Vector2(10.0f, 10.0f)); ...

C++ GUI Challenge

c++,graphics,programming-languages,monogame

As well as the truly graphical options like Qt, it is also worth considering a simpler one - ncurses. This essentially allows you to create GUI-like interfaces in a terminal and is supported on both Linux and Windows (via Cygwin/MinGW). This is an example that I made back in university...

Monogame + WP8.1 - Orientation resets after ApplyChanges

c#,windows-phone-8,orientation,monogame

Finally I was able to solve the issue: MonoGame 3.2.2. installer has corrupted template, so I deleted the old project that was created from the template and targeted Windows Phone 8.1, then created a new project, added MonoGame 3.2.2. libraries through NuGet, copied the MonoGame.dll into an 'Externals' folder and...

How do i implement Awesomium 1.7.4.2 in a Monogame project?

c#,monogame,awesomium

I have just got this working, you have to create a new thread, then call Run, then listen for an event to be raised by WebCore which will have created a new SynchronizationContext by then. You then want to keep a reference to that context on your main thread... Thread...

Instance Argument: Cannot convert an object to its own type

c#,build,xna,visual-studio-2013,monogame

MonoGame is most likely referencing a different version of XNA, or has used the same namespace for an alternate implementation to minimize code impact to end developers. See @ayls answer to this similar question Monogame Ambiguous Vector2 for an approach. Actually, this answer from @Andrew Russell looks even more authoritative...