Как создать платформер

3

Index

Taggé

Contributeurs

Statistiques

87,139 visites, 116,090 vues

Outils

Partager

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Добавление спрайта игрока

Давайте добавим спрайт для игрока. Как и прежде, сделайте двойной щелчок на пространстве макета, чтобы вставить новый объект, и выберите Sprite . Когда появится перекрестие, нажмите где-то над плиткой. Появится Image Editor.

Давайте импортируем спрайт-полосу анимации стоящего в покое игрока. Как и раньше, кликаем правкой кнопкой мыши по окну Animation Frames и выбираем Import sprite strip....

Выберите файл Player\Idle\Idle.png. Обратите внимание на то, что это полная спрайт-полоса,а не один из кадров анимации. Вы также можете импортировать последовательность файлов с Import frames..., но давайте придерживаться этого пути в настоящем проекте.

Поскольку спрайт-полоса не квадратной формы, Construct 2 сам пытается угадать количество кадров. Он должен правильно угадать, что в изображении 11кадров. Нажмите ОК и кадры импортируются.

Важно отметить, что самый первый кадр все еще пустой. Щелкаем правкой кнопкой мыши по нему и удаляем снова. Теперь у вас должна получиться секвенция из 11 кадров анимации игрока в состоянии покоя.

Обрезка

Вы могли заметить, что вокруг изображения игрока есть прозрачное пространство. Это часто встречается после импорта изображений. Однако, это плохо, оставлять его- на него расходуется память и оно может помешать взаимодействию между объектами.

Есть быстрый способ избавиться от него. Удерживайте shift и нажмите Crop -кнопка на панели инструментов редактора изображений.

Если не удерживать клавишу Shift, обрежется только 1 кадр, поэтому убедитесь, что зажали его, если хотите обрезать поля у всех кадров в анимации. Изображение игрока теперь должно быть красиво обрезано без дополнительных ненужных полей.

Setting the origin

The origin is the center, or "hot spot", of the object. In platformers, it's best to have the origin by the player's feet. This means if the animation changes height as it plays, they grow upwards, rather than in to the floor.

To set the origin, click the Set origin and image points tool in the image editor.

You should notice a red spot appear on the player. That's the origin. You can click to change it. However, we want it bottom-middle aligned. We can quickly assign this by hitting 2 on the num pad (if num lock is on). If you don't have a num pad (e.g. some laptops), you can right click Origin in the Image points window that popped up and choose Quick assign - Bottom.

It's a hassle to do this for each and every frame, but luckily there's another short-cut: in the Image points window that popped up, right click Origin and click Apply to whole animation.

Bingo! The origin should be set on every animation frame.

Loop the animation

Click the Default animation in the Animations window. Rename it to Idle.

In the Properties Bar, change the Speed of the animation to 9 and set Loop to Yes.

Right click the Idle animation in the Animations window and select Preview. You should see the player bobbing up and down gently. All done! Close the animation preview and the image editor. You should see your player in the layout.

Rename the object to Player in the Properties bar, since we're being organised.

  • 3 Comments

  • Order by
Want to leave a comment? Login or Register an account!