Tell the spritemap which animation to play when the scene starts The frames start counting from 0, and count from left-to-right, top-to-bottom Each 32x40 box is a single frame in our particular sprite map. An animation is made up of a group of frames, ranging from 1 frame to many frames. We must define each animation for our spritemap. Sprite = new Spritemap(Assets.PLAYER, 32, 40) Create a new spritemap, with the player.png image as our source, 32 pixels wide, and 40 pixels tall When creating a new player, the desired X,Y coordinates are passed in.
PIXEN SNAP TO GRID UPDATE
Third, update your Player’s constructor to match this one: public Player(float x = 0, float y = 0) Public const string BULLET = "././Assets/Graphics/bullet.png" Public const string PLAYER_PARTICLE = "././Assets/Graphics/particle.png" Public const string PLAYER_EXPLOSION = "././Assets/Graphics/explosion.png" Second, add the following lines to your Assets.cs class: public const string PLAYER = "././Assets/Graphics/player.png" First, add the following above your Player constructor: // Our entity's graphic will be a Spritemap We will save collision for a later entry.Īlright, time to start coding the player.
PIXEN SNAP TO GRID CODE
Keeping to our code organization from prior tutorials, right-click your ‘OtterTutorial’ project, select ‘Add New Folder’ and create a folder named ‘Entities’. That is about all I have to say about art, as I usually hire artists for my games :). As far as tools go, I suggest Pixen for Mac users, and Pickle for Windows. If you are looking to create your own pixel art and don’t know where to begin I suggest you take a look at this awesome tutorial. Within the popup, navigate to your ‘Assets/Graphics’ folder, select all of the new images, and click ‘Add’.
Next, add the images to your project by right-clicking your ‘Graphics’ folder and selecting Add->Existing Image. Make sure you save each graphic to your ‘Assets/Graphics’ folder.
PIXEN SNAP TO GRID ZIP
Either right-click and save each image below, or download this zip file containing all of our images. Save the player, bullet, particle, and explosion images displayed below. Time to get started!įirst, we should download the required graphics for this tutorial. In this entry, we will create an Entity for the player, implementing its walking and shooting abilities. Last time, we finished up our title screen, and loaded an empty Scene intended for our gameplay. Otter 2D Top-Down Adventure Tutorial (Part 4) - Adding the Player Entity