migrating cocos2dx to v2.1.5 - ios

First of all, I know this is such an outdated version. But I really need an answer. I'm very new to iOS and cocos2dx, I just got some old code and I'm trying to update cocos2dx to v2.1.5.
My problem is CCMutableArray has been deprecated, replaced with CCArray. I know that in the latest version CCArray has also been deprecated.
But my question is how do I properly update this part of the code without getting unexpected results...
static CCMutableArray<CCString*>* getCsvList(string path);
CCMutableArray<GiftInfo*>* giftList;
I believe I can't just do a drop-in replace like:
static CCArray<CCString*>* csvList(string path);
CCArray<GiftInfo*>* giftList;
Thanks.

you can use CCArray like this
static CCArray* csvList( string path );
CCArray* giftList;
CCArray* stringList;
//
//
//you can add object of CCObject class or derived from CCObject class to CCArray
//example
GiftInfo* gift = GiftInfo::create();
giftList->addObject(gift); //GiftInfo must derived from CCObject class
CCString* myString = CCString::create("new string");
stringList.addObject(myString);
//when getting value from CCArray, it will return object of CCObject, you have to cast it to your class
CCString* getValue = (CCString*)stringList.objectAtIndex( index );
GiftInfo* getGift = (GiftInfo*)giftList.objectAtIndex( index );
for more information see CCArray class inside cocos2d-x code.
Note: It is better to updatre to version 2.2.6 instead of 2.1.5, Its is latest version of cocos2d-x 2.x series.

Related

Incompatible OSAL interfaces in Rhapsody

I'm trying to create OSAL (Operating System Abstraction Layer) adapter for FreeRTOS but confused with the provided interfaces.
For example, init function of RiCOSTask is defined as follows in the docs :
RiCBoolean RiCOSTask_init (RiCOSTask *const me,
RiCOSTaskEndCallBack tfunc, void *param,
const char *name, const long stackSize);
https://www.ibm.com/support/knowledgecenter/SSB2MU_8.1.3/com.ibm.rhp.reference.doc/topics/rhp_r_fw_init_ricostask.html
But RiCTaskEM calls this function like below :
RiCBoolean RiCTaskEM_init(RiCBoolean wrapTask,RiCThread * const
itsThread,RiCBoolean isThread,const RiCOSTaskEntryCallBack cbkFunc,const
RhpAddress cbkParam,RhpPositive initStaticPeriod)
{
..........
(RhpVoid) RiCOSTask_init(&(itsThread->osTask), cbkFunc, cbkParam, initStaticPeriod);
...........
}
I guess something is wrong with my configuration. I'm using SMXF with Rhapsody 8.1.3.
Another issue is, init function of my test class calls the RiCTaskEM_init method like below :
void smxfTestClass_Init(smxfTestClass* const me, RiCTaskEM * p_task) {
RiCTaskEM_init(&(me->ric_task), RiCFALSE, &(me->ric_thread), RiCTRUE,
(RiCOSTaskEntryCallBack)smxfTestClass_doExecute, me, 0U);
.......
}
But if I set a property of my class, eg. ActiveThreadName, the call to RiCTaskEM_Init function is changed like this :
void smxfTestClass_Init(smxfTestClass* const me, RiCTaskEM * p_task) {
RiCTaskEM_Init(&(me->ric_task), "Test", RiCOSDefaultThreadPriority,
RiCOSDefaultStackSize, RiCOSDefaultMessageQueueSize, RiCFALSE, NULL);
......
}
And the compilation fails because the prototype of RiCTaskEM_Init is not compatible with the above call. It is defined like this :
RiCBoolean RiCTaskEM_init(RiCBoolean wrapTask,RiCThread * const
itsThread,RiCBoolean isThread,const RiCOSTaskEntryCallBack cbkFunc,const
RhpAddress cbkParam,RhpPositive initStaticPeriod)
What is happening ? Do I have a mismatch between the Rhapsody version and the SMXF model I am using ?
Why RiCTaskEM_init method is called in a different way if I set a property of my class ? The second version seems to be the correct one but provided RiCTaskEM_init method is not compatible with that.
Do I have to modify functions of RiCTaskEM somehow ? I guess no because it belongs to framework, not the adaptor and OSAL adaptor guide doesn't mention anything about it. But the current implementation simply does not fit.
The documentation is written for the OXF, not for the SMXF Framework. As far as I know there is no real documentation for adapting an SMXF but.. the SMXF is there as a model (Check your /LangC/smxf directory)
this should make it easier to create an adapter.
Do you really need the SMXF or would an OXF suffice (or even another Framework like RXF?
Walter

Understanding dart syntax

Coming from the java world I have difficulties to understand this code-fragment from the AngularDart pirate badge code lab:
Future _loadData() {
return _http.get('piratenames.json').then((HttpResponse response) {
PirateName.names = response.data['names'];
PirateName.appellations = response.data['appellations'];
});
}
}
From my understanding PirateName is a class and how can the line
PirateName.names = response.data['names'];
write a field of a class without referring to an actual instance?
Dart syntax allows static variables as does Java.
That is a static variable as defined in the source you provided Edit piratebadge.dart and you'll see where it is defined as static.

Why is this Repository Method not working?

I used this Repository Method in an Extbase Project and it worked fine.
public function findRandom() {
$rows = $this->createQuery()->execute()->count();
$row_number = mt_rand(0, max(0, ($rows - 1)));
return $this->createQuery()->setOffset($row_number)->setLimit(1)->execute();
}
It is not working in TYPO3 Flow. Why? And what should I change?
Sound strange Flow must return an object in this, like Extbase does, or in your case an QueryResultInterface of one object, if you need directly an object, you can use this kind of code:
$query->execute()->getFirst();
Hope that help,
I did not mention, the queryResult is not the object it self. Its an array. My code above is working.
This is a difference between extbase and flow3. Flow3 returns an array. Extbase the object itself.

T4MVC 2.6.65 and UseLowercaseRoutes=true error

Good day!
I'm using latest T4MVC from 2.6.65 from NuGet (upgraded from 2.6.64), I've set
// If true, use lower case tokens in routes for the area, controller and action names
static bool UseLowercaseRoutes = true;
And I got error:
The expression being assigned to '....' must be constant ...\T4MVC.cs
Here is the the generated code that triggers error:
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public class ActionNameConstants {
public const string Calc = ("Calc").ToLowerInvariant();
}
Is this a bug?
Ah sorry, the previous change broke it. I just pushed a new build of T4MVC (2.6.66) which addresses this. Well, it's more of a workaround as it basically doesn't generate the constant tokens when UseLowercaseRoutes is used. But that'll get us going for now.
The root of the problem is that C# doesn't support using .ToLowerInvariant() in constant strings. Ideally, it would just evaluate that at compile time, but it's not that smart :)

Graphics deprecation in blackberry game development

I had a problem on this matter, I'm using Eclipse with JDK 6.0
How can I resolve this problem:
Here's my code
public void processLevel(){
OBJ tempObjects;
if(mygfx.getBackPos() % 25 == 0){
tempObjects = new EnemyDrone(rndGenerator.nextInt() % Graphics.getScreenWidth(), 0 );
tempObjects.setY(tempObjects.getY() - tempObjects.getmybitmap().getHeight() + 3);
gameObjects.addElement(tempObjects);
}
}
the error says that "The method getScreenWidth() from the type Graphics is deprecated"
Thanks in advance guys.!!
Well, you should still be able to compile it with that code; deprecation is just a warning that the current way of doing something isn't the recommended way of doing it, and that there is a newer method that might have additional functionality or is better supported. In this case, you want to use Display.getWidth() to get the current width of the screen.
In general the documentation will say what method a deprecated method has been replaced with. For example, if you check out the documentation for the Graphics class in BB 6.0, it will say to use the static getWidth method of the Display class instead.
You should now use getWidth() of Display in net.rim.device.api.system.Display. The Deprecated API page is also useful.

Resources