1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/endlesstravel-love2dCS

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
README-getting-started.md 4 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
gitlife-traslator Отправлено 28.11.2024 05:56 4ba6e1b

Начало работы

  1. Создайте консольное приложение на C#.

  2. Установите Love2DCS из NuGet в Visual Studio.

  3. Поместите следующий код в файл (возможно, Program.cs) и сохраните его:

using Love;
namespace Example
{
    class Program : Scene
    {
        public override void Draw()
        {
            Graphics.Print("Hello World!", 400, 300);
        }

        public override void Update(float dt)
        {
            // обновление каждого кадра здесь ..
        }

        static void Main(string[] args)
        {
            Boot.Run(new Program());
        }
    }
}

Метод Scene будет вызываться так же, как он назван:

KeyPressed(KeyConstant key, Scancode scancode, bool isRepeat)
KeyReleased(KeyConstant key, Scancode scancode)
MouseMoved(float x, float y, float dx, float dy, bool isTouch)
MousePressed(float x, float y, int button, bool isTouch)
MouseReleased(float x, float y, int button, bool isTouch)
MouseFocus(bool focus)
WheelMoved(int x, int y)
JoystickPressed(Joystick joystick, int button)
JoystickReleased(Joystick joystick, int button)
JoystickAxis(Joystick joystick, float axis, float value)
JoystickHat(Joystick joystick, int hat, Joystick.Hat direction)
JoystickGamepadPressed(Joystick joystick, Joystick.GamepadButton button)
JoystickGamepadReleased(Joystick joystick, Joystick.GamepadButton button)
JoystickGamepadAxis(Joystick joystick, Joystick.GamepadAxis axis, float value)
JoystickAdded(Joystick joystick)
JoystickRemoved(Joystick joystick)
TouchMoved(long id, float x, float y, float dx, float dy, float pressure)
TouchPressed(long id, float x, float y, float dx, float dy, float pressure)
TouchReleased(long id, float x, float y, float dx, float dy, float pressure)
TextEditing(string text, int start, int end)
TextInput(string text)
WindowFocus(bool focus)
WindowVisible(bool visible)
WindowResize(int w, int h)
DirectoryDropped(string path)
FileDropped(File file)
Quit()
LowMemory()
Load()
Update(float dt)
Draw()
  1. Запустите игру: Debug/Start Debugging или нажмите F5.

Дополнительные примеры

  • Рисование изображения:
using Love;
namespace Example
{
    class Program : Scene
    {
        Image img = null;

        public override void Load()
        {
            img = Graphics.NewImage("logo.png");
        }

        public override void Update(float dt)
        {
            // update every frame here ..
        }

        public override void Draw()
        {
            Graphics.Draw(img, 300, 200);
        }

        static void Main(string[] args)
        {
            Boot.Run(new Program());
        }
    }
}
  • Воспроизведение звука:
using Love;
namespace Example
{
    class Program : Scene
    {
        Source source = null;

        public override void Load()
        {
            source = Audio.NewSource("music.mp3");
            source.play();
        }

        public override void Update(float dt)
        {
            // update every frame here ..
        }

        static void Main(string[] args)
        {
            Boot.Run(new Program());
        }
    }
}
  • Обработка события нажатия клавиши — нажмите Escape, чтобы выйти:
using Love;
namespace Example
{
    class Program : Scene
    {
        public override void KeyPressed(KeyConstant key, Scancode scancode, bool isRepeat)
        {
            if (KeyConstant.Escape == key)
                Event.Quit();
        }

        public override void Update(float dt)
        {
            // update every frame here ..
        }

        static void Main(string[] args)
        {
            Boot.Run(new Program());
        }
    }
}
  • Пустой проект — no-game Sence запустится автоматически:
class Program
{
    static void Main(string[] args)
    {
        Love.Boot.Run();
    }
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/endlesstravel-love2dCS.git
git@api.gitlife.ru:oschina-mirror/endlesstravel-love2dCS.git
oschina-mirror
endlesstravel-love2dCS
endlesstravel-love2dCS
master