ccsprite

how to obtain a CCSprite's width and height in cocos2d for iphone

给你一囗甜甜゛ 提交于 2019-12-02 20:16:42
That's the question xD Given an instance of a CCSprite in cocos2d in iphone, what method can I use to obtain the image width and height? The CCSprite class has a bounding box property that's a CGRect: CCSprite *sprite = [CCSprite spriteWithFile: @"file.png"]; int width = [sprite boundingBox].size.width; I added a width and height methods to my CCSprite subclass. -(CGFloat) width { return [self boundingBox].size.width; } -(CGFloat) height { return [self boundingBox].size.height; } yubenyi raw width: sprite.contentSize.width raw height: sprite.contentSize.height current width: sprite.contentSize

Cocos2d and iOS: Can't understand use of control points using ccBezierConfig

扶醉桌前 提交于 2019-12-02 08:14:10
问题 EDIT: If the question is badly written have a look at the video (3), same link as in the bottom of this page. I am trying to draw a very simple bezier curve using ccBezierConfig and Cocos2D. Reading on Wikipedia I tried to understand a bit controls points and found this image: http://upload.wikimedia.org/wikipedia/commons/thumb/b/bf/Bezier_2_big.png/240px-Bezier_2_big.png If you look on the wikipedia page from which I took the image there is a cool animation. Have a look here. This is the

CCSprite Fadeout with children

淺唱寂寞╮ 提交于 2019-12-01 19:55:00
I'm using a CCSprite with a few other CCSprite objects added as children, the other animations I'm using (scale and rotate) work great and the children are animated too. But when I'm using CCFadeOut , it only fades the parent. I've read that fadeout doesn't apply to the children. Is there any way other than iterating over every child and calling the fadeout on each of them? Mazyod This answer is rendered obsolete by Gregory Johnson Answer Well, I guess your choices are (Ranked from simplest to complex): 1) Just go into the CCSprite class in cocos2d library, and hack it. (<3 open source). ( not

Getting and setting the RGB / RGBA value of a pixel in a CCSprite (cocos2d-x)

孤者浪人 提交于 2019-11-30 09:59:18
Why do I need this? Basically I need to turn a color image into gray-scale. Including a gray-scale version of the image could be a solution, but space is tight in my situation - I don't want my APK to be too big. Besides, I would like to work on the pixels for some effects too. Again, this is to make the APK smaller. I have found getPixel setPixel from CCTexture2D and Getting image's pixel RGBA , but I would like something more simple. Any help is appreciated. Thank you! Here is my solution for you : 1.First make a CCImage version of your image: I) from File : CCImage *img= new CCImage(); img-

Getting and setting the RGB / RGBA value of a pixel in a CCSprite (cocos2d-x)

∥☆過路亽.° 提交于 2019-11-29 14:41:18
问题 Why do I need this? Basically I need to turn a color image into gray-scale. Including a gray-scale version of the image could be a solution, but space is tight in my situation - I don't want my APK to be too big. Besides, I would like to work on the pixels for some effects too. Again, this is to make the APK smaller. I have found getPixel setPixel from CCTexture2D and Getting image's pixel RGBA, but I would like something more simple. Any help is appreciated. Thank you! 回答1: Here is my

How to differentiate between iphone4 and iphone 3

孤街醉人 提交于 2019-11-26 09:16:02
问题 I am trying to build a game for the iphone using cocos2d engine. I wanted to know how can I tell a difference whether the user is using iphone 4 or iphone 3 as I wanted to load hi-resolution graphics for the iphone4 and low-resolution for iphone 3. I know if I use @2x.png at the end of the image file name UIImage loads the hi-resolution image by itself if I am using an iphone 4 but for the game I am using cocos2d engine\'s CCSprite class to load the graphics. I would really appreciate the