Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cocos2d: Make it works

Make it builds, and complete enough of the API to run a minimalist sample.
  • Loading branch information...
commit 70f86eb48238e15ec62a8c4cbc6cf633081691dc 1 parent 12b17e3
@StephaneDelcroix StephaneDelcroix authored
View
11 cocos2d/Makefile
@@ -1,9 +1,2 @@
-all: cocos2d.dll
-
-cocos2d.dll: Makefile cocos2d.cs
- /Developer/MonoTouch/usr/bin/btouch -d=MONOTOUCH -e cocos2d.cs enums.cs --sourceonly=list --tmpdir=ios
- /Developer/MonoTouch/usr/bin/smcs $(BUILD_FLAGS) -out:CorePlotiOS.dll -define:MONOTOUCH @list enums.cs extras.cs -r:monotouch.dll
-
-
-clean:
- -rm cocos2d.dll
+ASSEMBLY=Cocos2D.dll
+include ../Rules.make
View
121 cocos2d/cocos2d.cs → cocos2d/binding/ApiDefinition.cs
@@ -3,13 +3,17 @@
//
// Author:
// Miguel de Icaza
+// Stephane Delcroix
//
// Copyright 2011 Xamarin, Inc.
+// Copyright 2012 S. Delcroix
//
+
using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.ObjCRuntime;
+using MonoTouch.UIKit;
namespace MonoTouch.Cocos2D {
@@ -65,8 +69,8 @@ interface CCAction {
[Export ("action")]
CCAction CreateAction ();
- [Export ("init")]
- IntPtr Constructor ();
+ //[Export ("init")]
+ //IntPtr Constructor ();
//[Export ("copyWithZone:")]
//NSObject CopyFromZone (NSZone zone );
@@ -98,6 +102,25 @@ interface CCFiniteTimeAction {
}
+ [BaseType (typeof (NSObject))]
+ interface CCNode {
+ [Export ("zOrder")]
+ int ZOrder { get; set; }
+
+ [Export ("vertexZ")]
+ float VertexZ { get; set; }
+
+ [Static]
+ [Export ("node")]
+ CCNode Node { get; }
+
+ [Export ("addChild:")]
+ void Add (CCNode child);
+
+ [Export ("position")]
+ PointF Position { get; set; }
+ }
+
[BaseType (typeof (CCAction))]
interface CCRepeatForever {
[Export ("innerAction")]
@@ -464,4 +487,96 @@ interface CCAnimation {
}
-}
+ [BaseType (typeof (NSObject))]
+ interface CCSpriteFrame {
+ [Export ("rect")]
+ RectangleF Rect { get; set; }
+
+ [Export ("rectInPixels")]
+ RectangleF RectInPixels { get; set; }
+
+ [Export ("rotated")]
+ bool Rotated { get; set; }
+ }
+
+ [BaseType (typeof (NSObject))]
+ interface CCTexture2D {
+ [Static]
+ [Export("defaultAlphaPixelFormat")]
+ CCTexture2DPixelFormat DefaultAlphaPixelFormat { get; set; }
+
+ [Static]
+ [Export ("PVRImageHavePremultipliedAlpha")]
+ bool PVRImageHavePremultipliedAlpha { set; }
+ }
+
+ [BaseType (typeof (UIView))]
+ interface CCGLView {
+ [Static]
+ [Export ("viewWithFrame:")]
+ CCGLView View (RectangleF frame);
+ }
+
+ [BaseType (typeof(UIViewController))]
+ interface CCDirector {
+ [Static]
+ [Export ("sharedDirector")]
+ CCDirector SharedDirector { get; set; }
+
+ [Export ("displayStats")]
+ bool DisplayStats { get; set; }
+
+ [Export ("animationInterval")]
+ double AnimationInterval { get; set; }
+
+ [Export ("projection")]
+ CCDirectorProjection Projection { set; }
+
+ [Export ("pushScene:")]
+ void Push (CCScene scene);
+
+ [Export ("winSize")]
+ SizeF WinSize { get; }
+
+ [Export ("winSizeInPixels")]
+ SizeF WinSizeInPixels { get; }
+ }
+
+ [BaseType (typeof (CCNode))]
+ interface CCScene {
+
+ }
+
+ [BaseType (typeof (CCDirector))]
+ interface CCDirectorIOS {
+ [Export ("projection:")]
+ CCDirectorProjection Projection { set; }
+
+ [Export ("enableRetinaDisplay:")]
+ bool EnableRetinaDisplay (bool enableRetina);
+ }
+
+ [BaseType (typeof (CCNode))]
+ interface CCLayer {
+ [Export ("registerWithTouchDispatcher")]
+ void RegisterWithTouchDispatcher ();
+
+ [Export ("isTouchEnabled")]
+ bool IsTouchEnabled { get; set; }
+
+ [Export ("isAccelerometerEnabled")]
+ bool IsAccelerometerEnabled { get; set; }
+ }
+
+ [BaseType (typeof (CCSprite))]
+ interface CCLabelTTF {
+ [Static]
+ [Export ("labelWithString:fontName:fontSize:")]
+ CCLabelTTF Label (string label, string fontName, float fontSize);
+
+ }
+
+ [BaseType (typeof (CCNode))]
+ interface CCSprite {
+ }
+}
View
4 cocos2d/binding/AssemblyInfo.cs
@@ -0,0 +1,4 @@
+using System;
+using MonoTouch.ObjCRuntime;
+
+[assembly: LinkWith ("libcocos2d.a",LinkTarget.Simulator | LinkTarget.ArmV6 | LinkTarget.ArmV7, ForceLoad = true, Frameworks = "OpenGLES CoreGraphics QuartzCore")]
View
43 cocos2d/binding/Makefile
@@ -0,0 +1,43 @@
+XBUILD=/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
+BTOUCH=/Developer/MonoTouch/usr/bin/btouch
+SMCS=/Developer/MonoTouch/usr/bin/smcs
+VERSION=2.0
+PROJECT_ROOT=cocos2d-iphone-$(VERSION)
+PROJECT_TGZ=$(PROJECT_ROOT).tar.gz
+PROJECT=$(PROJECT_ROOT)/cocos2d-ios.xcodeproj
+TARGET=cocos2d
+
+all: Cocos2D.dll
+
+$(PROJECT_TGZ):
+ curl http://cocos2d-iphone.googlecode.com/files/$(PROJECT_TGZ) -o $(PROJECT_TGZ)
+
+$(PROJECT): $(PROJECT_TGZ)
+ tar xfz $<
+
+lib$(TARGET)-i386.a: $(PROJECT)
+ $(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphonesimulator -configuration Release clean build
+ -mv $(PROJECT_ROOT)/build/Release-iphonesimulator/lib$(TARGET).a $@
+
+lib$(TARGET)-armv6.a: $(PROJECT)
+ $(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphoneos -arch armv6 -configuration Release clean build
+ -mv $(PROJECT_ROOT)/build/Release-iphoneos/lib$(TARGET).a $@
+
+lib$(TARGET)-armv7.a: $(PROJECT)
+ $(XBUILD) -project $(PROJECT) -target $(TARGET) -sdk iphoneos -arch armv7 -configuration Release clean build
+ -mv $(PROJECT_ROOT)/build/Release-iphoneos/lib$(TARGET).a $@
+
+lib$(TARGET).a: lib$(TARGET)-i386.a lib$(TARGET)-armv6.a lib$(TARGET)-armv7.a
+ lipo -create -output $@ $^
+
+Cocos2D.dll: ApiDefinition.cs StructsAndEnums.cs AssemblyInfo.cs lib$(TARGET).a
+ mkdir -p ios
+ #$(BTOUCH) -e ApiDefinition.cs -s StructsAndEnums.cs AssemblyInfo.cs --tmpdir=ios --out=$@ --link-with=lib$(TARGET).a,lib$(TARGET).a
+ $(BTOUCH) -unsafe ApiDefinition.cs -s StructsAndEnums.cs --tmpdir=ios --sourceonly ios/sources.list
+ $(SMCS) -noconfig -o- -out:$@ -res:libcocos2d.a AssemblyInfo.cs StructsAndEnums.cs @ios/sources.list -target:library -unsafe -reference:/Developer/MonoTouch/usr/lib/mono/2.1/System.dll -reference:/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll -reference:/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll
+
+clean:
+ -rm -f *.a *.dll
+
+clean-all: clean
+ -rm -rf $(PROJECT_ROOT) $(PROJECT_TGZ) ios
View
23 cocos2d/enums.cs → cocos2d/binding/StructsAndEnums.cs
@@ -17,4 +17,25 @@ public struct CCBezierConfig {
public PointF ControlPoint1;
public PointF ControlPoint2;
}
-}
+
+ public enum CCDirectorProjection {
+ TwoD,
+ ThreeD,
+ Custom,
+ Default = TwoD,
+ }
+
+ public enum CCTexture2DPixelFormat {
+ Rgba8888,
+ Rgb888,
+ Rgb565,
+ A8,
+ I8,
+ AI88,
+ Rgba4444,
+ Rgb5a1,
+ Pvrtc4,
+ Pvrtc2,
+ Default = Rgba8888
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.