Exemplo n.º 1
0
        private void InitUI()
        {
            int count = 0;

            for (int i = 0; i < 2; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    if (count < 3)
                    {
                        int index = count;
                        var bt    = new CozyColorSampleButton(100, 100, CCColor4B.Blue, CCColor4B.Green)
                        {
                            Text     = string.Format("level : {0}", index),
                            Position = new CCPoint(i * (100 + 10), j * (100 + 10)),
                            OnClick  = () =>
                            {
                                FarmMapLogic.EnterMap(index);
                            }
                        };
                        this.AddChild(bt);
                        dispatcher.Add(bt);
                        ++count;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void ApplicationDidFinishLaunching(CCApplication application, CCWindow mainWindow)
        {
            SharedWindow = mainWindow;

            DefaultResolution = new CCSize(
                application.MainWindow.WindowSizeInPixels.Width,
                application.MainWindow.WindowSizeInPixels.Height);

            application.ContentRootDirectory = "Content";

            CCScene scene = new CCScene(mainWindow);
            CCLayer layer = new IntroLayer(DefaultResolution);

            var b = new CozyColorSampleButton(100, 100, 158, 158)
            {
                NormalColor  = new CCColor4B(255, 0, 0),
                ClickedColor = new CCColor4B(0, 255, 0),
                Text         = "Hello Bttton",
                HasBorder    = true,
            };

            b.OnClick += () =>
            {
            };

            var list = new CozySampleListView()
            {
                ContentSize = new CCSize(350, 350),
                Orientation = ControlOrientation.Vertical,
                Position    = new CCPoint(100, 100),
                HasBorder   = true,
            };

            layer.AddChild(list);

            list.AddItem(new CozySampleListViewItemSprite(new CCSprite("gold"))

            {
                MarginBottom = 10,
                MarginTop    = 10,
                HasBorder    = true,
            });
            list.AddItem(b);
            list.AddItem(new CozySampleListViewItemSprite(new CCSprite("gold"))

            {
                MarginBottom = 10,
                MarginTop    = 10,
                HasBorder    = true,
            });

            layer.AddEventListener(b.EventListener, layer);

            scene.AddChild(layer);
            mainWindow.RunWithScene(scene);
        }