I'm migrating my apps from cocos2d v2.x to v3.x, first of all I'm not going to use spritebuilder. so in 2.0 there were 4 different resolutions for every sprite.
sprite.png/iphone
sprite-hd.png/iphone retina
sprite-ipad.png/ipad
sprite-ipadhd.png/ipad retina
the same approach as i see is not working for v3.0,the question is, what is the solution for v3.0?
also tried to add the following code manually in app delegate, but no result
[[CCFileUtils sharedFileUtils] setiPadRetinaDisplaySuffix:#"-ipadhd"];
[[CCFileUtils sharedFileUtils] setiPadSuffix:#"-ipad"];
[[CCFileUtils sharedFileUtils] setiPhoneRetinaDisplaySuffix:#"-hd"];
This is what i am doing with 3.2
NSDictionary *dic = [CCFileUtils sharedFileUtils].suffixesDict;
[dic setValue:#"-hd" forKey:CCFileUtilsSuffixDefault];
[dic setValue:#"-hd" forKey:CCFileUtilsSuffixiPhone] ;
[dic setValue:#"-hd" forKey:CCFileUtilsSuffixiPad];
[dic setValue:#"-hd" forKey:CCFileUtilsSuffixiPadHD];
[dic setValue:#"-hd" forKey:CCFileUtilsSuffixiPhoneHD];
[dic setValue:#"-hd" forKey:CCFileUtilsSuffixiPhone5];
[dic setValue:#"-hd" forKey:CCFileUtilsSuffixiPhone5HD];
put whatever suffix values are appropriate for your app.
Found solution.
To use custom sprites with spritebuilder , I've moved all my sprites to ccbResources folder and put them into appropriate subfolders.
then to acces them I'm using
[CCSprite spriteWithImageNamed:#"ccbResources/sprite.png"];
Related
I'm trying to fit a line model from a pointcloud. I'm using pcl 1.9.1. And I'm facing this error :
[pcl::RandomSampleConsensus::computeModel] No samples could be selected
[pcl::SACSegmentation::segment] Error segmenting the model! No solution found.
The pointclouds I want to use are like this one :
https://drive.google.com/file/d/1qLrVjplmqT_SdFUXaZCYAkWHtYVEoTKR/view?usp=sharing
The code I'm using is almost the exact same as the tutorial's one (https://pcl.readthedocs.io/projects/tutorials/en/latest/planar_segmentation.html#planar-segmentation):
pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients);
pcl::PointIndices::Ptr inliers (new pcl::PointIndices);
// Create the segmentation object
pcl::SACSegmentation<pcl::PointXYZ> seg;
// Optional
seg.setOptimizeCoefficients (true);
// Mandatory
seg.setModelType (pcl::SACMODEL_LINE);
seg.setMethodType (pcl::SAC_RANSAC);
seg.setDistanceThreshold (0.1);
seg.setInputCloud (m_Lcloud);
seg.segment (*inliers, *coefficients);
The only difference is the fact I want to use a line model instead of a plane one. I don't know what is happening because I saw several people doing the same and not facing this problem. I didn't see the error in this context on any topic.
My pointcloud is not so big (like 300 points) but I don't think that's the problem. I already tried to make it bigger (just added symmetrics or things like this) but same error.
The threshold is also not the problem (I think). I tried a lot of these and normally with 0.1 it should be good.
Maybe it's my version of PCL that have a problem. If someone with a latest version could try, I would appreciate.
I'm posting here because the pcl forum doesn't seem to be still active. So sorry if this shouldn't be here.
Thanks to anyone who takes some time for helping me !
Code:
var bg = CCSprite(imageNamed:"Background.png")
Images used in Resource:
Background-hd.png
Background-ipad.png
Background-ipadhd.png
Background-iphone5hd.png
Background.png
In all device Background.png(320x480) used, other images are ignored. How to fix this ?
Retina display is not enabled...How to enable retina display in v3 ?
Here is working sample code with this problem.
I'm not really advanced user of SpriteBuilder but have some concerns about your issue.
As you are using Sprite Builder for starting the project, it configures your CCFileUtils to distinguish different devices' resources by looking at folders, not prefixes. In your app delegate you can see this line:
[CCBReader configureCCFileUtils];
going into this method you can see that search mode for file utils is set to CCFileUtilsSearchModeDirectory
sharedFileUtils.searchMode = CCFileUtilsSearchModeDirectory;
So you need to use Publish folders and copy your Background image to each of them with the same name (Background.png), but with different resolution for each device.
You don't need to use image suffixes in SpriteBuilder at all.
Finally Updated Cocos2d and now -hd,-ipad files are used. Just updated one line
sharedFileUtils.searchMode = CCFileUtilsSearchModeSuffix
For some reason my UIButtons aren't appearing in my ruby motion apps. Only the button text appears.
Here's the code:
#containerView = UIView.alloc.initWithFrame([[0, 50], [self.view.frame.size.width, 100]])
#loginButton = UIButton.buttonWithType(UIButtonTypeRoundedRect)
#loginButton.frame = [[(self.view.frame.size.width / 2) + 5, 65], [(self.view.frame.size.width / 2) - 15, 40]]
#loginButton.setTitle('Login', forState: UIControlStateNormal)
#loginButton.addTarget(self,
action:'login',
forControlEvents:UIControlEventTouchUpInside)
#containerView.addSubview(#loginButton)
self.view.addSubview(#containerView)
I'm using RubyMotion v2.16, Promotion 1.0.4, sugarcube 1.3.5, motion layout 0.0.1 and bubblewrap 1.4.0
I've tried to render the buttons using the promotion way, the sugarcube way and the bubblewrap way but decided to break it down to the raw rubymotion way (above) for troubleshooting in a regular view controller. Any ideas on this one?
Well, if anyone else is reading outdated documentation also, it turns out that UIButtonTypeRoundedRect has been deprecated in iOS7.
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/TransitionGuide/Controls.html#//apple_ref/doc/uid/TP40013174-CH9-SW1
Why am I getting this warning and how can I fix it?
I'm using Kobold2D v2.1.0 (Uses cocos2d-iphone v2.1 and OpenGL ES 2.0)
My code:
CCMenuItemSprite *flareButton = [CCMenuItemSprite itemFromNormalSprite:flareSprite selectedSprite:flareSelectedSprite target:self selector:#selector(flareSelected)];
Can you also tell me how I can avoid these deprecations in the future by looking at a reference of any kind. Thanks
Look into ccDeprecated.m - you'll find all deprecated methods there as well as the correct (changed) way to use the function.
Deprecated in cocos2d means in almost all cases that the name of the function, the parameter list or its location have changed. You can also disable deprecation warnings in Build Settings and just ignore it for at least until the next major cocos2d update.
You can try with:
CCMenuItemSprite *flareButton = [CCMenuItemSprite itemWithNormalSprite:flareSprite selectedSprite:flareSprite target:self selector:#selector(flareSelected)];
Change From to With on itemFromNormalSprite: will be itemWithNormalSprite:
I'm not sure what I did - I was coding away merrily.. I think it might have something to do with updating Xcode to 4.1.1, but all of a sudden, when I build and run my project, the following compiler warning shows up in about 20 different cocos2d modules..
'format specifies unsigned int but the argument has ['CCTimer'] (or whatever module it's in)
the line in question in the cocos2d module is:
return [NSString stringWithFormat:#"<%# = %08X | target:%# selector:(%#)>", [self class], self, [target class], NSStringFromSelector(selector)];
and it's the '%08X' that's causing the problem..
And since this error, I can't compile on my iphone, although it runs fine in the simulator. I updated my phone OS to the latest, but it didn't help..
Has anyone else had this?
That's one of many format strings in cocos2d trying to print out the pointer value. While %08X works the correct way to do this is to use %p. So you can change the line to this:
[NSString stringWithFormat:#"<%# = %p | target:%# selector:(%#)>", [self class], self, [target class], NSStringFromSelector(selector)];
You will have to change all these lines, there's about a dozen or so of them.
Example output for anyone curious what the difference looks like:
%08X: 0976DC80
%p: 0x976dc80
PS: I have recently fixed all these incorrect cocos2d logs in Kobold2D.