Cocos2d-Swift v3.x Sprite Builder : In iPad iPhone sd images are used. -ipad suffix ignored - cocos2d-iphone

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

Related

OMNeT ++ direct message transmission visualizations in 3D

I am new to OMNeT++ and I'm trying to implement a drone network that communicate with each other using direct messages.
I want to visualize my drone network with the 3D visualization in OMNeT using the OsgVisualizer in inet.visualizer.scene package.
In the dronenetwork.ned file, I have used the IntegratedVisualizer and the OsgGeographicCoordinateSystem. Then in the omnetpp.ini file, the map file to be used is defined and so the map loading and mobility of the drones works fine in the 3D visualization of the simulation run.
However, the message transmissions between the drones are not visualized in 3D even though this is properly visualized in the 2D canvas mode.
I tried adding both NetworkNodeOsgVisualizer and NetworkConnectionOsgVisualizer to my drone module as visualization simple modules and also I have defined the drones as a #networkNode and #networkConnectionNode. But it still hasn't been able to visualize the message transmissions.
Any help or hint regarding this would be highly appreciated.
Code used for visualizations in the simple module drone is as follows
import inet.visualizer.scene.NetworkNodeOsgVisualizer;
import inet.visualizer.scene.NetworkConnectionOsgVisualizer;
module drone
{
parameters:
#networkNode;
#networkConnection;
submodules:
networkNodeOsgVisualizer: NetworkNodeOsgVisualizer {
#display("p=207,50");
displayModuleName = true;
visualizationTargetModule = "^.^";
visualizationSubjectModule = "wirelessInterface.^.^";
}
networkConnectionOsgVisualizer : NetworkConnectionOsgVisualizer{
visualizationTargetModule = "^.^";
visualizationSubjectModule = "wirelessInterface.^.^";
displayNetworkConnections = true;
}
Thank you
Message passing and direct message sending visualizations are special cases implemented by the Qtenv automatically for 2D (default) visualization only. You can add custom 2D message visualization (like the one in the aloha example). OMNeT++ does not provide any 3D visualization by default. All the code must be provided by the model (INET in this case). This is also true for any transient visualization. There is an example for this in the osg-earth omnet example where communication between cows are visualized by inflating bubbles.
So, you have to implement your own visualization effect. There is something in INET which is pretty close to what you want: DataLinkOsgVisualizer and PhysicalLinkOsgVisualizer which flashes an arrow if communication on data link or physical layer has occurred. This is not the same as message passing, but close enough. Or you can implement your own animation using these visualizers as a sample.

Warning after initializing particle effects in Cocos2dx - "libpng warning: iCCP: known incorrect sRGB profile"

I am trying to load particle effects (in .plist format) in my Cocos2d-x game code, and I am facing the warning: "libpng warning: iCCP: known incorrect sRGB profile", as mentioned in the question. I have done some research on my end, and the other StackOverflow users who asked similar questions had this issue while loading .png files.
However, I am facing the same issue while initializing .plist files instead. Any insight on how to remove this warning would be helpful. Kindly note that I am not facing any issue with loading the .plist file as such, but the warnings are polluting my log streams.
Sample code:
ParticleSystem* testStar = testNode->getChildByName<ParticleSystem*>("star");
testStar->initWithFile(filePath + "/" + "test.plist"); //valid filePath
testStar->setVisible(true);
Also, to confirm that this isn't an issue with the .plist file itself, I tried loading the file manually on my UI editor tool, and that seemed to load it without any issues.
I am ready to provide more details on my environment if necessary. I tried doing the above in a blank project as well, and I was able to reproduce the same warning.
Cocos2d-x version: cocos2d-x-3.14.1
I was able to solve this by using a sub-class of ParticleSystem instead of ParticleSystem itself. The sub-class I used is ParticleSystemQuad. Additionally, I realized that the initWithFile API was being called multiple times in my code, due to Cocos2D update schedulers. That may have been a cause for this warning.
To fix this warning, I created a fresh variable/system, and assigned a parent to it, while setting the position of the new variable to that of a well-known (desired position) node.
/* Getting the desired particleEffect position */
const Vec2& desiredPos = testNode->getChildByName("blablablah")->getPosition();
std::string filePath = "/"; //assign a directory for the .plist
// Avoid exponentiation
if (!testNode->getChildByName("sampleParticle")) {
auto p1 = ParticleSystemQuad::create(filePath + "/" + "test.plist");
p1->setPosition(desiredPos);
p1->resetSystem();
p1->setName("sampleParticle");
p1->setVisible(true);
testNode->addChild(p1);
}

Using ApplescriptObjC to convert color spaces of an image using NSColorSpace and iccProfileData

I have some code that will change an images colorspace from RGB to a GenericCMYK profile. I would like to be able to use an ICC Profile to convert the image to a CMYK colorspace. There is a way to do this in Photoshop, but the process takes too much of a users time when you are dealing with 100's of images, I am trying to create an AppleScript droplet that will do this for them.
I have already looked at the page for NSColorspace and there looks like there is a way to do this. I just have no idea how to convert this Objective-C into ApplescriptObjC. Here are the two references to the ICC Profiles in NSColorSpace:
init?(iccProfileData: Data)
Initializes and returns an NSColorSpace object given an ICC profile.
var iccProfileData: Data?
The ICC profile data from which the receiver was created.
Here is the code I have thanks to Shane at Macscripter.net:
set theImage to (current application's NSImage's alloc()'s initWithContentsOfURL:theInput)
set imageRep to (theImage's representations()'s objectAtIndex:0)
set targetSpace to current application's NSColorSpace's genericCMYKColorSpace()
set bitmapRep to (imageRep's bitmapImageRepByConvertingToColorSpace:targetSpace renderingIntent:(current application's NSColorRenderingIntentPerceptual))
set theProps to (current application's NSDictionary's dictionaryWithObjects:{1.0, true} forKeys:{current application's NSImageCompressionFactor, current application's NSImageProgressive})
set jpegData to (bitmapRep's representationUsingType:(current application's NSJPEGFileType) |properties|:theProps)
set colorSpace to bitmapRep's colorSpaceName() as text
(jpegData's writeToURL:theOutput atomically:true)
I just need to figure out how to include the ICC Profile as a part of the CMYK conversion process that happens I believe on this line of code:
set targetSpace to current application's NSColorSpace's genericCMYKColorSpace()
Can anyone give me some guidance on this?
Thanks!
You are looking at the NSColorSpace documentation in Swift. AppleScriptObjC is an Objective-C bridge, so it makes more sense viewing the documentation in Objective-C (the language can be set in the page header), where your snippet becomes
set targetSpace to current application's NSColorSpace's alloc's initWithICCProfileData:iccData
where iccData is the ICC profile data you are going to use.

cocos2dx running exported Json from cocos studio into an animation

I'm trying to read/load an exported JSON and resources from CocosStudio(this is a tool to generate animations)
But when i try to load or read is seams that the isn't any class or function in order to load this file. I did a web research and all i found were deprecated code or external libraries etc..
thinks like:
auto animation animation = extension::ccSkeletonAnimation::createWithFile("FILE.JSON","FILE.ATLAS");
animation->setPosition((x+y));
animation->setAnimation("a",true);
this->addChild(animation,0);
The code above is using an external tool similar to "cocosStudio", called "Spin"
Is it any that can provide some guidance on this...? or the proper class to set an animation a JSON file?
The cocos2dx version is 3.1
Thanks in advance!
Best regards!
I'm using this code to import animation from cocostudio to visual studio 12
cocostudio::Armature* armature;
ArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("DemoPlayer0.png","DemoPlayer0.plist","DemoPlayer.ExportJson");
armature = Armature::create("DemoPlayer");
armature->setPosition(ccp(visibleSize.width * 0.8,visibleSize.height * 0.5));
armature->getAnimation()->playByIndex(0);
armature->setScale(0.25);
this->addChild(armature);
Or you can check this code in help section of cocostudio.
//async loading export file
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("Cowboy0.png","Cowboy0.plist","Cowboy.ExportJson");
//Creat armature by name
CCArmature *armature = CCArmature::create("Cowboy");
//play animation by animation index
armature->getAnimation()->playByIndex(0);
//Change Permissions
armature->setScale(0.5f);
//Set the armature position
armature->setPosition(200,300);
//add to the current scene
this->addChild(armature,2)
Good luck !

Getting an incorrect permissions screen in the webview Blackberry 10 Cascades Beta 3 SDK in Dev Alpha Simulator

I am trying to make dynamically generated html 5 graphs show up in a webview in Blackberry 10 Cascades. I have confirmed the html5 that I have generated, draws the correct graphs. My problem is that when I try to implement this in the Blackberry 10 Cascades Beta 3 SDK (using the Blackberry 10 Dev Alpha Simulator), the webview that is supposed to show the graph, just looks like this:
Here is the code that leads to this error:
//html_ already contains the html-5 code to make the graph at this point in the code
//This is the file path to a local file that is actually accessable in the emulator
//and not just from Windows
//
QFile *chartFile = new QFile("app/native/assets/data/chart.html");
if (chartFile->open(QIODevice::WriteOnly)) {
chartFile->write(html_.toUtf8());
chartFile->flush();
chartFile->close();
}
if (chartFile) delete chartFile;
if (graphView_) {
graphView_->setHtml("");
graphView_->setUrl(QUrl::fromLocalFile("app/native/assets/data/chart.html"));
}
I checked the permissions of that file, put they are all Allow (777 permissions for those who know Unix style permissions).
I added access_internet to the bar-descriptor.xml, eventhough my app was already able to access remote sites, just to see if that would fix it, but it did not.
I've been searching around trying to find a solution to this problem, but I have not.
If anyone could help me out with this, it would be greatly appreciated.
-------------------------------------------------------
Update:
I changed the code to set the html directly, now I have this:
if (graphView_) {
graphView_->setHtml(html_, QUrl("app/native/assets/data/chart.html"));
}
But nothing shows. It seems I have the wrong relative path relative to my base url.
My base url is this: QUrl("app/native/assets/data/chart.html")
My relative paths all begin with: ./Highcharts/js/...
My relative paths are located under: app/native/assets/data/Highcharts/js
It seems to me that I this should work, but when I do this, I just a blank screen, as if it can not find my relative paths. So I don't know what's going on here either.
I found a solution that works. I'm using the first approach, not the updated approach, but instead of
graphView_->setUrl(QUrl("app/native/assets/data/chart.html"));
I'm using:
graphView_->setUrl(QUrl("local:///assets/data/chart.html"));
And I have left the rest of the code the same, and it works.