Tested with cocos2dx: 3. Chapters Why Cocos2d-X? Being Creative Tuning the Mind. It may be helpful to add a delay between animation frames. With V-Play, we do apply a similar approach to the one described by you here. To support all kinds of aspect ratios and screen resolutions, we also use content scaling and bigger backgrounds to avoid black bars at non ratios.
Hi Chris, nice article. The list of aspect ratios is quite handy. And yes, feel free to link to this article. I was wondering what your thoughts were on the max dimensions for a sprite sheet? Would you suggest the same for mid-level phones? This will help immensely to give you some peace of mind. As for background sizes, those numbers sound fine. Hi guys. If I wanted to use a graphics set like HD, but scale it a little to fit the device screen dimensions dynamically On a PC or Mac for instance in a resolution independent way, can Cocos2d-x support that with TexturePacker files?
Is it just a scale factor of some sort that I can apply to everything? So you set tour spritesheet however you want it in TexturePacker, then dynamically resize with Cocos2d-x.
A bit cheeky, but… would be very cool if you could show a port of this to cocos2d html 5 :. Great tutorial! One thing to point out about the use of setResourceDirectory for setting the resource directory.
As this is deprecated now, you should update your tutorial to use setSearchPaths instead. The function name has been changed. Open up CCFileUtils. Hi thank you for this post I create a new sprite sheet for my game but the problem is i dont know why new sprite appear inverted in the screen?? Can you try disabling rotations and see if that fixes it? Macro Enums. EventType Enums. EmitterMode Enums.
PositionType Enums. Mode Enums. Direction Enums. FillType Enums. SizeMode Enums. SpriteType Enums. WrapMode Enums. Orientation Enums. AnimationEventType Enums. Sprite Module: cc. Sprite ; node. Properties spriteFrame SpriteFrame. The sprite frame of the sprite. Vec2 0, 0 ;. Node private. The node this component is attached to. A component is always attached to a node. Indicates whether the object is not yet destroyed. Methods setVisible visible. Sets whether the sprite is visible or not.
Query the sprite's original size. Change the left sprite's cap inset. Query the left sprite's cap inset. Change the top sprite's cap inset. Query the top sprite's cap inset. Change the right sprite's cap inset.
Query the right sprite's cap inset. Change the bottom sprite's cap inset. Query the bottom sprite's cap inset. Update is called every frame, if the Component is enabled. LateUpdate is called every frame, if the Component is enabled. When attaching to an active node or its node first activated. Called before all scripts' update if the Component is enabled. Called when this component becomes enabled and its node is active. Called when this component becomes disabled or its node becomes inactive.
Called when this component will be destroyed. Adds a component class to the node. Returns the component of supplied type if the node has one attached, null if it doesn't. Returns all components of supplied Type in the node. Returns the component of supplied type in any of its children using depth first search. Returns the components of supplied type in any of its children using depth first search. If the component's bounding box is different from the node's, you can implement this method to supply a custom axis aligned bounding box AABB , so the editor's scene view can perform hit test properly.
This function is only called in editor mode. Schedules a custom selector. Schedules a callback function that runs only once, with a delay of 0 or larger.
Unschedules a custom callback function. Clear all references in the instance. Called before the object being destroyed. Sliced mode : the image is cut up into a 9-slicing and according to certain rules is scaled to fit freely set dimensions size. It is usually used in UI elements or to make images that can be enlarged infinitely without influencing the image quality into images cut up into a grid to save game resource space. Tiled mode : The image will be repeated to fit the size of the Sprite.
If the SpriteFrame is 9-sliced , when the image is tiled, the surrounding width will remain unchanged while the other sections will be repeated. Filled mode : draws a portion of the original picture in a certain direction and scale, based on the origin and fill mode settings.
Often used for dynamic display of progress bars. Mesh mode : Only support. So let's explain their roles in turn. Fill Range determines the total amount of padding, which fills the entire circle when Fill Range is set to 1. A counter anticlockwise fill when Fill Range is positive, and is filled clockwise when negative.
I am going to assume you have a working AppDelegate, so I will only focus on creating a new scene object. The only changes you should have to make are to change your delegate to include a different file and change the type of scene you call createScene on.
First we are going to need an image to draw. Personally I am going to use this somewhat… familiar image:. Of course you can use whatever image you want. Just be certain to add the image to the resources directory of your project.
Hmmm, probably not exactly what you expected to happen, but hey, congratulations, you just rendered your first sprite!
This is telling the sprite to position itself at the pixel location 0,0. There are two things we can take away from the results.
One of the most confusing things when working in 2D graphics is dealing with all the various coordinate systems. There are two major approaches to dealing with locations in 2D, having the location 0,0 at the top left of the screen and having the location 0,0 at the bottom left of the screen. This point is referred to as the Origin. It is common for UI systems, the most famous of which being Windows, to set the origin at the top left of the screen.
It is also most common for graphics files to store their image data starting from the top left pixel, but by no means is this universal. On the other hand OpenGL and most mathematicians treat the bottom left corner of the screen as the origin.
0コメント