Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        private void InitUI()
        {
            var listlable = new CCLabel("佣兵列表", StringManager.GetText("GlobalFont"), 14)
            {
                Position = new CCPoint(100, 420),
                Color    = CCColor3B.White
            };

            FollowerList = PlayerObject.Instance.Self.AllFollower;
            Page         = (FollowerList.Followers.Count + 8) / 9;

            AddChild(listlable, 100);

            foreach (var obj in FollowerList.Followers)
            {
                var fs = new FollowerSprite(obj, true);
                this.AddChild(fs);
                SpriteList.Add(fs);
            }

            var listview = new CozySampleListView()
            {
                ContentSize = new CCSize(600, 330),
                HasBorder   = true,
                Position    = new CCPoint(100, 60)
            };

            this.AddChild(listview);

            InnerList = new CozySampleListView[3];
            for (int i = 0; i < 3; ++i)
            {
                InnerList[i] = new CozySampleListView()
                {
                    ContentSize = new CCSize(200, 330),
                    Orientation = Public.Controls.Enum.ControlOrientation.Vertical,
                };
                listview.AddItem(new CozySampleListViewItem(InnerList[i]));
            }

            int fight = PlayerObject.Instance.Self.FightFollower.Followers.Count;

            AllFollower = new CCLabel("总数" + fight + "/" + FollowerList.Followers.Count, StringManager.GetText("GlobalFont"), 14)
            {
                Position = new CCPoint(92, 37),
                Color    = CCColor3B.White,
            };
            AddChild(AllFollower, 100);

            PageNumber = new CCLabel((CurPage + 1) + "/" + Page, StringManager.GetText("GlobalFont"), 14)
            {
                Position = new CCPoint(389, 37),
                Color    = CCColor3B.White
            };
            AddChild(PageNumber, 100);

            ShowDetail = new FollowerDetailSprite()
            {
                Position    = new CCPoint(100, 100),
                AnchorPoint = CCPoint.Zero,
                Visible     = false,
                FightStatusChangeCallback = new Action <Follower>(OnStatusChange),
            };
            this.AddChild(ShowDetail, 201);

            LastPageButton = new CozySampleButton(473, 17, 78, 36)
            {
                Text     = "上一页",
                FontSize = 14,
                OnClick  = () => PrevPage(),
            };
            NextPageButton = new CozySampleButton(585, 17, 78, 36)
            {
                Text     = "下一页",
                FontSize = 14,
                OnClick  = () => NextPage(),
            };
            AddChild(NextPageButton, 100);
            AddChild(LastPageButton, 100);
            uidispatcher.Add(NextPageButton);
            uidispatcher.Add(LastPageButton);

            var backButton = new CozySampleButton(650, 17, 78, 36)
            {
                Text     = "返回",
                FontSize = 14,
                OnClick  = () =>
                {
                    AppDelegate.SharedWindow.DefaultDirector.PopScene();
                }
            };

            AddChild(backButton, 100);
            uidispatcher.Add(backButton);
        }