Skip to content

Instantly share code, notes, and snippets.

@xlab
Created March 3, 2012 19:07
Show Gist options
  • Save xlab/1967571 to your computer and use it in GitHub Desktop.
Save xlab/1967571 to your computer and use it in GitHub Desktop.
CocosNET (cocos2d port) + Monotouch, my first app
using System;
using CocosNet.Layers;
using CocosNet.Labels;
using System.Drawing;
using CocosNet;
using CocosNet.Menus;
using MonoTouch.UIKit;
using CocosNet.Support;
using CocosNet.Sprites;
using CocosNet.Actions;
namespace MyTest
{
public class BallScene : ColorLayer
{
protected Sprite ball;
public BallScene ()
{
SizeF s = Director.Instance.WinSize;
//Заголовок
Label label = new Label("Прыгающий мячик", "Arial", 32);
label.SetPosition(s.Width / 2f, s.Height - 50);
AddChild(label, 9999);
//Кнопка для меню
MenuItemImage item1 = new MenuItemImage("button.png", "button.png");
item1.Click += HandleItem1Click;
//Меню
Menu menu = new Menu(item1);
menu.SetPosition(s.Width / 2f, s.Height - 150);
AddChild(menu, 9999);
//Мяч
ball = new Sprite("ball.png");
ball.SetPosition(50, 50);
AddChild(ball, 1);
}
void HandleItem1Click (object sender, EventArgs e)
{
//MessageBox.Show("Кнопка нажата", "Привет!");
var jump = new JumpBy(2, new PointF(230, 0), 50, 5);
ball.RunAction(new Sequence(jump, jump.Reverse() as IntervalAction));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment