In this Nintendo Web Framework game development tutorial, we'll look at the draw component. In Rokko.js, the Draw component class is an abstraction over HTML5 canvas so we can draw to the screen. The execute method of this component takes an entity, a timestamp, and renders it to its CanvasRenderingContext2D. Since every entity has an (x, y) position in game space, as well as a Sprite object that graphically represents it, the draw component extracts this information from the entity, and performs the rendering of the entity object. Before we have a sprite class in place, we will simply draw each entity as a rectangle rooted at the entity's position, using its width and height to determine its dimensions. Later we will stop using the entity's size, and will instead use the width and height of the sprite that represents the image. Because of this, we're able to dynamically change the entity's size in case each sprite in the animation loop has a slightly different size.
Copyright © 2014-2017 EasyLearnTutorial. All rights reserved.