Sepertinya Anda menggunakan alat otomatisasi untuk menelusuri situs web kami. Mohon verifikasi bahwa Anda bukan robot Referensi ID 14acea7c-0af6-11ee-89fa-41484a694b73 Ini mungkin terjadi karena hal berikut Javascript dinonaktifkan atau diblokir oleh ekstensi misalnya pemblokir iklan Browser Anda tidak mendukung cookie Pastikan Javascript dan cookie diaktifkan di browser Anda dan Anda tidak memblokirnya.
There are different ways to create Sprites depending upon what you need to accomplish. You can create a Sprite from an image with various graphic formats including PNG, JPEG, TIFF, and others. Let's go through some create methods and talk about each one. Creating a Sprite A Sprite can be created by specifying an image file to use. auto mySprite = Spritecreate" The statement above creates a Sprite using the image. The result is that the created Sprite uses the whole image. Sprite has the same dimensions of If the image file is 200 x 200 the resulting Sprite is 200 x 200. Creating a Sprite with a Rect In the previous example, the created Sprite has the same size as the original image file. If you want to create a Sprite with only a certain portion of the image file, you can do it by specifying a Rect. Rect has 4 values origin x, origin y, width and height. auto mySprite = Spritecreate" Rect0,0,40,40; Rect starts at the top left corner. This is the opposite of what you might be used to when laying out screen position as it starts from the lower left corner. Thus the resulting Sprite is only a portion of the image file. In this case the Sprite dimension is 40 x 40 starting at the top left corner. If you don't specify a Rect, Cocos2d-x will automatically use the full width and height of the image file you specify. Take a look at the example below. If we use an image with dimensions 200 x 200 the following 2 statements would have the same result. auto mySprite = Spritecreate" auto mySprite = Spritecreate" Rect0,0,200,200; results matching "" No results matching ""
Imageand V ideo Processing 161. detection helps in early diagnosis of the pr oblem and enhancements ca n be. made in the structures to prevent an y major disaster. is chapter mainly. focuses on.
Introduction Letās start things off with one of the most basic building blocks of a 2D game in any game engine, creating a Sprite. This will introduce us to the Cocos Creator user interface, illustrate how to import assets into our game, show how nodes are defined, and of course, draw a Sprite on screen. Assets We are going to need some sprites and other assets throughout this entire project. I am using the awesome free pixel art package available at Pixel Game Art. Obviously feel free to replace with whatever assets you have at hand, but if you want to follow along exactly, I recommend you download that asset pack. Extract the assets out into a folder somewhere on your hard drive. Importing Sprites Letās start things off organized. Locate the Assets tab, Name your newly created folder āspritesā, simple drag and drop the image files you want to use into this folder. The asset you just dropped in is now available for usage in your game. You can also simply drop files into the project folder using your native file system file browser. Simply right-click the folder within the asset panel and select Open In Explorer. Any files you add to the file system will automatically be imported into your project. Now that we have a graphic to work with, letās create a sprite open in our game. Locate the Node Tree panel, make sure that Canvas is selected, then click the + Icon. Whatever item you have selected will automatically be the parent of the created node. A child automatically inherits positioning information from itās parent. Once youāve clicked the + link, select Create Renderer Nodes->Sprite Node You will notice that this action created a new Node initially named New Sprite, with a Component of type Sprite. Cocos Creator is a component-based game engine, where all of the things that are drawn on the screen are implement as Nodes, and those nodes contain one or more components. You could have created the exact same result by creating an empty node and adding a Sprite component with it. We will explore adding components to nodes in more detail in the future. The most important property we care about right now is Sprite Frame in the Sprite component. This is where we attach our image asset to the sprite node. Simply drag and drop again, this time from assets to sprite frame You will now notice that your sprite is available and drawn by default centered inside itās parent node in the Scene panel. This panel is where you can layout the various visible nodes that compose your scene. There is a toolbar for switching between the various transformation options. You can also switch between these options using Wmove, Erotate, Rscale, Trectangle. They are all fairly self-explanatory except perhaps rect. Using the Rect tool you can scale and rotate a node using the corners or center point. Now that weāve successfully created a sprite, letās look at some of the key properties. You will notice the manipulator for our sprite object is relative to its center. This means when you translate or rotate this node, itās done relative to its mid-point. Often people prefer to instead draw relative to a different point, the bottom left-hand corner is the most common alternative. This can easily be set using the Anchor property This is a normalized value, from to A value of is the bottom left corner, is the top left corner, while is the top right-hand corner. This value is available to every single node type. This anchor value also sets positioning relative to the parent. So, for example with our canvas anchor set to child nodes at will be drawn in the middle. Speaking of that Canvas node, letās take a closer look at its properties. The design resolution tells Cocos what resolution you want to work at, and most importantly, how to deal with it when that resolution doesnāt match. Therefore, if you are working with low pixel images letās instead work with a different resolution, such as 320Ć240. You will notice as itās changed, the purple rectangle depicting the boundaries of the viewport. The Fit Width and Fit Height checkbox tell Cocos how to stretch the resolution in case the device you are running on is a different resolution. Cocos will automatically take care of the scaling, black bars, etc. Once we are ready to test out our game locate the play icon at the top of the screen and click the play icon. You can run in either the Simulator or in a web browser. You can control the dimensions of the simulator by selecting Cocos Creator->Preferences⦠You can now select the resolution using Simulator Resolution, or define your own resolution using the Custom option.