How to apply FBMemoryProfiler to cocos2d-x iOs game? - ios

I want to apply the FBMemoryProfiler for cocos2dx iOs game.
First, I create a simple demo, "cocos new CocosGame -p com.test -l cpp". There are a lot of projects of the demo, like proj.ios_mac, proj.android, proj.linux...
I chose the ios_mac one and it works fine.
Then, I create a podfile to import the FBMemoryProfiler in proj.ios_mac and I use podfile to install FBMemoryProfiler.
However, when I open the CococsGame.xcworkkspace, there are a lot of errors, like
cannot find libFBAllocationTracker.a
I really want to know how to apply FBMemoryProfiler for cocos2d, what am I doing wrong?

You need to include FBAllocationTracker in your demo first.
You can do that by including the following
import FBAllocationTracker
in the headers and in the main method
FBAllocationTrackerManager.sharedManager()?.startTrackingAllocations()
into your main.swift
PS: You might wanna enable Generations by adding the following line with the above :
FBAllocationTrackerManager.sharedManager()?.enableGenerations()
If you have already done the above and still getting the same error, it looks like your project is not linking the FBAllocationTracker properly and you might wanna look at the https://github.com/facebook/FBMemoryProfiler "Usage" section again to see if you are missing something.

Related

Localization Behavior simply not working

I'm trying to test the localization feature in Polymer.
I've created a new App using the new CLI.
It gives you a nice scaffolding of an app. In there I've added the code from the app-localize-behavior docs to enable it but it simply doesn't work. By doesn't work I mean that the {{localize(...)}} line doesn't show anything.
You can find my sample code in the link below:
https://gist.github.com/dallarosa/daaac2d8959026a05c1eef1d65493d6b
This is really just the scaffolding plus the entries related to app-localize-behavior, so in the gist I've only added the related code. Let me know if you actually wanna see the whole contents.
I just very quickly looked at the issue, and it looks ok to me at first glance... except for possibly requiring to 'type' your language property:
language: {type: String, value: 'en'}

TypeError: Error #2023: Class Main$ must inherit from Sprite to link to the root. Feathers

Ok, hopefully this problem is easily reproducible:
git clone https://github.com/joshtynjala/feathers
Create Flash Builder project and point it to the TileList example in the examples folder.
Make sure to select Main.as (not TileList.as) as the main file. It is a few folders deep.
I am debugging on my iPhone - not sure what happens with an emulator but I'm assuming I would get the same error. So when I do, Run -> Debug, it loads fine - but when I click on the app to open it on my phone, this error pops up in Flash Builder:
TypeError: Error #2023: Class Main$ must inherit from Sprite to link to the root.
Not sure what this means - I found a few things on google, but nothing has lead me to any success.
My problem was with step 3 in my outline above - I needed to make the TileList.as the main file instead of Main.as (not sure why TileList.as isn't called Main.as) - I also needed to add all the icon images to the main source folder because they weren't there (maybe something that needs to be corrected on the feathers repo).
you must extend Sprite to your main class.
import flash.display.Sprite
public class Main extends Sprite{
}

Changing the Gridpanel class in Gridworld

I am trying to follow the steps to change the Gridworld appearance according to this. I've already imported source code for my gridworld jar file; ie. I can go and look at Bug.class or Gridpanel.class if I wanted to. However, I can't edit these files to produce the results that that pdf suggests. How do I do this? Did I import the source code incorrectly?
I don't think you can edit an external resource like gridworld.jar. You are going to need to create 4 new packages:
actor
grid
gui
world
Then copy the class files from gridworld.jar packages into your corresponding ones. Now you can edit the files. Make sure you include any miscellaneous files that might also be in the gridworld.jar packages, their important.
With your own packages you no longer need the gridworld.jar external resource, and there is a difference in your import statements. Instead of
import gridworld.actor.Actor;
Do this:
import actor.Actor;
Note: You will need to change all of the import statements in the new package classes to reference the other new packages. I believe that there were also some errors, not project breaking, but I just added suppressors.

Expected identifier for every occurance of "(Class)class" in LARSAdController

I'm currently trying to add LARSAdController to my iOS project with no success.
As soon as i import the files via #import "LARSAdController.h" in my AppDelegate.h the build process fails and on every occurance of (Class)class in LARSAdController.h i get the cryptic error "Expected identifier". BTW I'm using cocoapods.
Example:
- (void)registerAdClass:(Class)class;
which seems fine to me...
If i create a blank project and import the files they compile, so the problem must be in some relation to my code. Anyone got an idea what may cause this?
Thanks for any help in advance!
class is a reserved word in C++, so I would imagine that some of your project uses Objective-C++.
To solve this, use #import LARSAdController.h in Objective-C implementation files only, and remove its use from header files. You can use #class to forward-declare any occurrences of whatever classes are defined in LARSAdController.h in header files (this is best-practise anyway).
If you need to use LARSAdController from an Objective-C++ class then this is more complicated and you will need to use an Objective-C proxy object or modify their header files (which isn't ideal).

ShapeCache not being set up-- plist file not being loaded?

So I asked a slightly similar question to this one but did not get it answered so I figured I would look into it more myself and narrow my problem down to make it more simple.
In my Box2D game I am using Physics Editor to deal with my collision detection. In my main class (GameLayer), I have a method which sets up the ShapeCache and I put it in the init:
- (void)setupShapeCache
{
[[ShapeCache sharedShapeCache] addShapesWithFile:#"shapes.plist"];
}
"shapes.plist" is in my targets (under copy bundle resources) and it's in my resources folder of my project with the same name as it is used throughout my xcode project.
As I run my game I keep getting an assertion failed error in my ShapeCache class. I have figured out that this is because the "shapes.plist" file never loads.
The exact error looks like:
Assertion failed: (so), function -[ShapeCache addFixturesToBody:forShapeName:userdataCallBack:],
file /Users/***/Desktop/***/***/ShapeCache.mm, line 92.
My ShapeCache class is adapted from the Space Game Starter Kit but I do not believe that that makes a difference (SpaceGame ShapeCache vs PhysicsEditor ShapeCache)
Does anyone have any idea as to why my physics editor plist (shapes.plist) never loads?
If any more information would help please tell me!
Thank you so much!
:)

Resources