Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
[cocos2d.PhysicsSystem] Migrate sample to unified
Browse files Browse the repository at this point in the history
  • Loading branch information
olegoid committed Jan 19, 2015
1 parent 8a346e8 commit 5cfa948
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
4 changes: 2 additions & 2 deletions cocos2d/samples/PhysicsSystem/PhysicsSystem/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Linq;

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;

using MonoTouch.Cocos2D;

Expand Down
12 changes: 9 additions & 3 deletions cocos2d/samples/PhysicsSystem/PhysicsSystem/Chipmunk#.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3459A5CA-A1A2-4F80-87B7-2EBD1196C522}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>PhysicsSystem</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>PhysicsSystem</AssemblyName>
<TargetFrameworkIdentifier>Xamarin.iOS</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>True</DebugSymbols>
Expand Down Expand Up @@ -44,6 +46,7 @@
<ConsolePause>False</ConsolePause>
<MtouchDebug>True</MtouchDebug>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchArch>ARMv7</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>none</DebugType>
Expand All @@ -53,6 +56,7 @@
<WarningLevel>4</WarningLevel>
<ConsolePause>False</ConsolePause>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchArch>ARMv7, ARM64</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
<DebugType>none</DebugType>
Expand All @@ -64,6 +68,7 @@
<ConsolePause>False</ConsolePause>
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
<CodesignKey>iPhone Distribution</CodesignKey>
<MtouchArch>ARMv7, ARM64</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
<DebugType>none</DebugType>
Expand All @@ -74,15 +79,16 @@
<ConsolePause>False</ConsolePause>
<CodesignKey>iPhone Distribution</CodesignKey>
<CodesignProvision>Automatic:AppStore</CodesignProvision>
<MtouchArch>ARMv7, ARM64</MtouchArch>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
<Reference Include="Cocos2D">
<HintPath>..\..\..\binding\Cocos2D.dll</HintPath>
</Reference>
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
Expand All @@ -96,7 +102,6 @@
<Compile Include="MachineLayer.cs" />
<Compile Include="DeviceExtensions.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<BundleResource Include="Resources\cylinder-ipad.png" />
<BundleResource Include="Resources\piston-ipad.png" />
Expand All @@ -115,4 +120,5 @@
<BundleResource Include="Resources\Icon.png" />
<BundleResource Include="Resources\Icon-72.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

using MonoTouch.UIKit;
using UIKit;

namespace PhysicsSystem
{
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/samples/PhysicsSystem/PhysicsSystem/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<integer>2</integer>
</array>
<key>MinimumOSVersion</key>
<string>5.0</string>
<string>5.1.1</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
Expand Down
25 changes: 13 additions & 12 deletions cocos2d/samples/PhysicsSystem/PhysicsSystem/MachineLayer.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using System.Drawing;
using CoreGraphics;

using MonoTouch.Cocos2D;
using MonoTouch.UIKit;
using UIKit;
using Chipmunk;
using System.Drawing;

namespace PhysicsSystem
{
Expand All @@ -27,19 +28,19 @@ public MachineLayer ()
};

Add ( new CCSprite ("bg.jpg") {
Position = UIDevice.CurrentDevice.IsIPad() ? new PointF(512, 384) : new PointF(240, 160),
Position = UIDevice.CurrentDevice.IsIPad() ? new CGPoint(512, 384) : new CGPoint(240, 160),
});

//motorblock, no body, no shape
var motorblock = new CCSprite ("motor_block.png") {
Position = UIDevice.CurrentDevice.IsIPad() ? new PointF (160, 460) : new PointF (80, 230),
Position = UIDevice.CurrentDevice.IsIPad() ? new CGPoint (160, 460) : new CGPoint (80, 230),
};
Add (motorblock);

//motorwheel
var motorwheel = new CCPhysicsSprite ("motor_wheel.png") {
Body = new Body (1, Helper.MomentForCircle (1, 20, 20, PointF.Empty)),
Position = UIDevice.CurrentDevice.IsIPad() ? new PointF (160, 460) : new PointF (80, 230),
Position = UIDevice.CurrentDevice.IsIPad() ? new CGPoint (160, 460) : new CGPoint (80, 230),
};
Add (motorwheel);

Expand All @@ -51,7 +52,7 @@ public MachineLayer ()
//wheel
var wheel = new CCPhysicsSprite ("wheel.png") {
Body = new Body (25, Helper.MomentForCircle (25, 140, 140, PointF.Empty)),
Position = UIDevice.CurrentDevice.IsIPad() ? new PointF (160, 300) : new PointF (80, 150),
Position = UIDevice.CurrentDevice.IsIPad() ? new CGPoint (160, 300) : new CGPoint (80, 150),
};
space.Add (wheel.Body);
space.Add (new CircleShape (wheel.Body, UIDevice.CurrentDevice.IsIPad() ? 140 : 70, PointF.Empty){Group = 1});
Expand All @@ -61,7 +62,7 @@ public MachineLayer ()

//cylinder. no physics body. only a shape
Add (new CCSprite ("cylinder.png") {
Position = UIDevice.CurrentDevice.IsIPad() ? new PointF (570, 300) : new PointF (285, 150),
Position = UIDevice.CurrentDevice.IsIPad() ? new CGPoint (570, 300) : new CGPoint (285, 150),
});

//space.Add (new PolygonShape (space.StaticBody, new [] {
Expand All @@ -81,7 +82,7 @@ public MachineLayer ()
//piston
var piston = new CCPhysicsSprite ("piston.png") {
Body = new Body (8, float.PositiveInfinity), //never rotates
Position = UIDevice.CurrentDevice.IsIPad() ? new PointF (370, 300) : new PointF (185, 150),
Position = UIDevice.CurrentDevice.IsIPad() ? new CGPoint (370, 300) : new CGPoint (185, 150),
};
space.Add (piston.Body);
space.Add (new PolygonShape (piston.Body, UIDevice.CurrentDevice.IsIPad() ? 100 : 50, UIDevice.CurrentDevice.IsIPad() ? 200 : 50) {Group = 1});
Expand All @@ -95,7 +96,7 @@ public MachineLayer ()
new PointF (160, 20),
new PointF (160, -20),
}, PointF.Empty)),
Position = UIDevice.CurrentDevice.IsIPad() ? new PointF (190, 300) : new PointF (95, 150)
Position = UIDevice.CurrentDevice.IsIPad() ? new CGPoint (190, 300) : new CGPoint (95, 150)
};
space.Add (conrod.Body);
space.Add (new PolygonShape (conrod.Body, UIDevice.CurrentDevice.IsIPad() ? 320 : 160, UIDevice.CurrentDevice.IsIPad() ? 40 : 20) {Group = 1});
Expand All @@ -105,9 +106,9 @@ public MachineLayer ()
space.Add ((Constraint)new PivotJoint (conrod.Body, piston.Body, UIDevice.CurrentDevice.IsIPad() ? new PointF (340, 300) : new PointF (170, 150)));
space.Add ((Constraint)new GrooveJoint (space.StaticBody,
piston.Body,
UIDevice.CurrentDevice.IsIPad() ? new PointF (0, 300) : new PointF (0, 150),
UIDevice.CurrentDevice.IsIPad() ? new PointF (1024, 300) : new PointF (480, 150),
UIDevice.CurrentDevice.IsIPad() ? new PointF (0, 0): new PointF (0, 0)));
UIDevice.CurrentDevice.IsIPad() ? new PointF (0, 300) : new PointF (0, 150),
UIDevice.CurrentDevice.IsIPad() ? new PointF (1024, 300) : new PointF (480, 150),
UIDevice.CurrentDevice.IsIPad() ? new PointF (0, 0): new PointF (0, 0)));

}

Expand Down
4 changes: 2 additions & 2 deletions cocos2d/samples/PhysicsSystem/PhysicsSystem/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Linq;

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;

namespace PhysicsSystem
{
Expand Down

0 comments on commit 5cfa948

Please sign in to comment.