This repository was archived by the owner on Jan 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample demonstrating how to create a custom class that will buffe…
…r all the triangle and line vertices so they can be re-used later if need be. There is an feature enhancment setup here: mono/CocosSharp#293
- Loading branch information
Showing
43 changed files
with
2,365 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
DrawNodeBuffer/DrawNodeBuffer/DrawNodeBuffer.Droid/Assets/AboutAssets.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Any raw assets you want to be deployed with your application can be placed in | ||
this directory (and child directories) and given a Build Action of "AndroidAsset". | ||
|
||
These files will be deployed with you package and will be accessible using Android's | ||
AssetManager, like this: | ||
|
||
public class ReadAsset : Activity | ||
{ | ||
protected override void OnCreate (Bundle bundle) | ||
{ | ||
base.OnCreate (bundle); | ||
|
||
InputStream input = Assets.Open ("my_asset.txt"); | ||
} | ||
} | ||
|
||
Additionally, some Android functions will automatically load asset files: | ||
|
||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); |
Binary file added
BIN
+37.2 KB
DrawNodeBuffer/DrawNodeBuffer/DrawNodeBuffer.Droid/Assets/Content/fonts/MarkerFelt-22.xnb
Binary file not shown.
121 changes: 121 additions & 0 deletions
121
DrawNodeBuffer/DrawNodeBuffer/DrawNodeBuffer.Droid/DrawNodeBuffer.Droid.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{3F85C462-7BE3-4D71-8F06-28106F07B74D}</ProjectGuid> | ||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>DrawNodeBuffer.Droid</RootNamespace> | ||
<AssemblyName>DrawNodeBuffer.Droid</AssemblyName> | ||
<FileAlignment>512</FileAlignment> | ||
<AndroidApplication>true</AndroidApplication> | ||
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> | ||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> | ||
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk> | ||
<AndroidStoreUncompressedFileExtensions /> | ||
<MandroidI18n /> | ||
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion> | ||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Android\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;ANDROID</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime> | ||
<AndroidLinkMode>None</AndroidLinkMode> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Android\Release\</OutputPath> | ||
<DefineConstants>TRACE;ANDROID</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> | ||
<AndroidLinkMode>SdkOnly</AndroidLinkMode> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="box2d, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\CocosSharp.PCL.Shared.1.5.0.1\lib\MonoAndroid10\box2d.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="CocosSharp, Version=1.5.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\CocosSharp.PCL.Shared.1.5.0.1\lib\MonoAndroid10\CocosSharp.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Lidgren.Network, Version=2012.1.7.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\CocosSharp.PCL.Shared.1.5.0.1\lib\MonoAndroid10\Lidgren.Network.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="Mono.Android" /> | ||
<Reference Include="MonoGame.Framework, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\..\packages\CocosSharp.PCL.Shared.1.5.0.1\lib\MonoAndroid10\MonoGame.Framework.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="mscorlib" /> | ||
<Reference Include="OpenTK" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs"> | ||
<SubType>Code</SubType> | ||
</Compile> | ||
<Compile Include="Resources\Resource.Designer.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<AndroidAsset Include="Assets\Content\fonts\MarkerFelt-22.xnb" /> | ||
<None Include="packages.config" /> | ||
<None Include="Resources\AboutResources.txt" /> | ||
<None Include="Assets\AboutAssets.txt" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<AndroidResource Include="Resources\Values\Strings.xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Folder Include="Assets\Content\hd\animations\" /> | ||
<Folder Include="Assets\Content\hd\fonts\" /> | ||
<Folder Include="Assets\Content\hd\images\" /> | ||
<Folder Include="Assets\Content\ld\animations\" /> | ||
<Folder Include="Assets\Content\ld\fonts\" /> | ||
<Folder Include="Assets\Content\ld\images\" /> | ||
<Folder Include="Assets\Content\sounds\" /> | ||
<Folder Include="Resources\Layout\" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<AndroidResource Include="Resources\Drawable\Splash.png" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<AndroidResource Include="Resources\Values\Styles.xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<AndroidResource Include="Resources\Drawable\icon.png" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\DrawNodeBuffer\DrawNodeBuffer.csproj"> | ||
<Name>DrawNodeBuffer</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="Properties\AndroidManifest.xml" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
47 changes: 47 additions & 0 deletions
47
DrawNodeBuffer/DrawNodeBuffer/DrawNodeBuffer.Droid/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Diagnostics; | ||
|
||
using Android.Content.PM; | ||
using Android.App; | ||
using Android.Content; | ||
using Android.OS; | ||
using Android.Provider; | ||
using Android.Views; | ||
using Android.Widget; | ||
using Uri = Android.Net.Uri; | ||
using Microsoft.Xna.Framework; | ||
|
||
using CocosSharp; | ||
using DrawNodeBuffer; | ||
|
||
namespace DrawNodeBuffer.Droid | ||
{ | ||
|
||
[Activity(Label = "DrawNodeBuffer.Droid" | ||
, MainLauncher = true | ||
, Icon = "@drawable/icon" | ||
, Theme = "@style/Theme.Splash" | ||
, AlwaysRetainTaskState = true | ||
, LaunchMode = Android.Content.PM.LaunchMode.SingleInstance | ||
, ScreenOrientation = ScreenOrientation.SensorLandscape | ||
, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden)] | ||
public class Program : AndroidGameActivity | ||
{ | ||
|
||
protected override void OnCreate(Bundle bundle) | ||
{ | ||
base.OnCreate(bundle); | ||
|
||
CCApplication application = new CCApplication(); | ||
application.ApplicationDelegate = new AppDelegate(); | ||
|
||
this.SetContentView(application.AndroidContentView); | ||
|
||
application.StartGame(); | ||
|
||
} | ||
} | ||
|
||
|
||
} | ||
|
5 changes: 5 additions & 0 deletions
5
DrawNodeBuffer/DrawNodeBuffer/DrawNodeBuffer.Droid/Properties/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="DrawNodeBuffer.Droid" android:versionCode="1" android:versionName="1.0"> | ||
<uses-sdk /> | ||
<application android:label="DrawNodeBuffer.Droid" android:icon="@drawable/Icon"></application> | ||
</manifest> |
41 changes: 41 additions & 0 deletions
41
DrawNodeBuffer/DrawNodeBuffer/DrawNodeBuffer.Droid/Properties/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using Android.App; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("DrawNodeBuffer.Droid")] | ||
[assembly: AssemblyProduct("DrawNodeBuffer.Droid")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyCopyright("Copyright © 2013")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("ad7890a1-a4cd-423c-9e5a-4dc7ff1bcc21")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] | ||
|
||
// Add some common permissions, these can be removed if not needed | ||
[assembly: UsesPermission(Android.Manifest.Permission.Internet)] | ||
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)] |
44 changes: 44 additions & 0 deletions
44
DrawNodeBuffer/DrawNodeBuffer/DrawNodeBuffer.Droid/Resources/AboutResources.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Images, layout descriptions, binary blobs and string dictionaries can be included | ||
in your application as resource files. Various Android APIs are designed to | ||
operate on the resource IDs instead of dealing with images, strings or binary blobs | ||
directly. | ||
|
||
For example, a sample Android app that contains a user interface layout (Main.xml), | ||
an internationalization string table (Strings.xml) and some icons (drawable/Icon.png) | ||
would keep its resources in the "Resources" directory of the application: | ||
|
||
Resources/ | ||
Drawable/ | ||
Icon.png | ||
|
||
Layout/ | ||
Main.axml | ||
|
||
Values/ | ||
Strings.xml | ||
|
||
In order to get the build system to recognize Android resources, the build action should be set | ||
to "AndroidResource". The native Android APIs do not operate directly with filenames, but | ||
instead operate on resource IDs. When you compile an Android application that uses resources, | ||
the build system will package the resources for distribution and generate a class called | ||
"Resource" that contains the tokens for each one of the resources included. For example, | ||
for the above Resources layout, this is what the Resource class would expose: | ||
|
||
public class Resource { | ||
public class Drawable { | ||
public const int Icon = 0x123; | ||
} | ||
|
||
public class Layout { | ||
public const int Main = 0x456; | ||
} | ||
|
||
public class String { | ||
public const int FirstString = 0xabc; | ||
public const int SecondString = 0xbcd; | ||
} | ||
} | ||
|
||
You would then use Resource.Drawable.Icon to reference the Drawable/Icon.png file, or | ||
Resource.Layout.Main to reference the Layout/Main.axml file, or Resource.String.FirstString | ||
to reference the first string in the dictionary file Values/Strings.xml. |
Binary file added
BIN
+48 KB
DrawNodeBuffer/DrawNodeBuffer/DrawNodeBuffer.Droid/Resources/Drawable/Splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.9 KB
DrawNodeBuffer/DrawNodeBuffer/DrawNodeBuffer.Droid/Resources/Drawable/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions
96
DrawNodeBuffer/DrawNodeBuffer/DrawNodeBuffer.Droid/Resources/Resource.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
DrawNodeBuffer/DrawNodeBuffer/DrawNodeBuffer.Droid/Resources/Values/Strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="ApplicationName">DrawNodeBuffer.Droid</string> | ||
</resources> |
7 changes: 7 additions & 0 deletions
7
DrawNodeBuffer/DrawNodeBuffer/DrawNodeBuffer.Droid/Resources/Values/Styles.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<style name="Theme.Splash" parent="android:Theme"> | ||
<item name="android:windowBackground">@drawable/splash</item> | ||
<item name="android:windowNoTitle">true</item> | ||
</style> | ||
</resources> |
Oops, something went wrong.