Cocos2D logging "[Action update]. override me" in every tick - cocos2d-iphone

Is this a problem? I believe that the warning:
[Action update]. override me
comes from directly calling [myAction update] on my own action. Which I'm not doing.
Can I just comment out the log warning? This gives me a dirty feeling. But everything seems to work fine...
This was in Cocos2D 1.1 and also in 2.0rc2.

You probably created a class that inherits from CCAction. Some code in CCAction will call the 'update' method. So 1) either you did not provide an 'update' method in your class, or 2) in your classe's update method your are invoking [super update]. If you really have nothing to do in the update cycle, just put an empty procedure in your class.
-(void) update:(ccTime) dt{
}

Try using [CCEaseOut actionWithDuration:xxx]

Related

Custom ACTION as fixture member - google test

I want to execute an action every time a mock function is called. I tried implementing this using ACTION_P. See the code below:
ACTION_P(CompleteRegistrationWithStatus, status)
{
arg1->registrationCompleted(status);
}
And the expectation goes like:
EXPECT_CALL(*mockObj, register(_)).WillOnce(CompleteRegistrationWithStatus(success));
Problem is, I had to use the same expectation multiple times, just different status. So I needed to put the expectation inside a member function of the test fixture to avoid code redundancy. But the function cannot access the ACTION_P I defined since it is not a member of the fixture.
I tried searching for ACTIONs that are fixture members, like that of MATCHERs, but to no avail.
Any suggestions for a possible solution or alternative? Any form of help is much appreciated. TIA!
I'm not sure that I understand the need to put the expectation in a member function of the fixture, but you should be able to get the behavior you want using InSequence:
{
InSequence s;
EXPECT_CALL(*mockObj, register(_))
.WillOnce(CompleteRegistrationWithStatus(success));
EXPECT_CALL(*mockObj, register(_))
.WillOnce(CompleteRegistrationWithStatus(failure));
}

Ember: adding a mixin to a class after it's been created

I want to add a mixin to an Ember class which has already been created. (The class is defined in a library, actually Ember itself; it's LinkView).
I see that we can do mixin.apply(obj), but this applies the mixin to an instance of the class. I want to add the mixin to the class, so it's automatically mixed-in to all newly created objects.
I attempted to override the init method of the class, using reopenClass, and do mixin.apply(this) there, to apply the mixin to the instance, and then call the original init method, but this does not seem to work because the mixin wiring is set up in the init method and it's already too late by the time I can get to it.
reopenClass does not seem to accept a mixin argument like extend does. Its code seems to suggest that it's doing something with mixins, but whatever it is it doesn't work:
a = Ember.Object.extend().reopenClass(Ember.Mixin.create({mixval: 1});
a.create().get('mixval'); // undefined
I know that I could create my own class with MyLinkView = Ember.LinkView.extend(mixin, ..., but unfortunately the original class name is referenced explicitly within the library, so I really would prefer to figure out how to extend that original class with my mixin.
I experimented with Ember.LinkView = Ember.LinkView.extend(mixin, .... This somehow seems dangerous, although it seems to work. But in this particular case it doesn't help me since the reference within the Ember code (in the definition of the {{link-to}} helper) is to an internal version of the class, not the fully qualified Ember.LinkView.
Any ideas?
The solution is simply
Klass = Parent.extend({init: {...}});
Mixin = Ember.Mixin.create({init: {...}});
Klass.reopen(mixin);
Everything works as expected, including the super chain. In other words, a call to Klass.create().init() will call the mixin's init, and a call to super from there will call the original Klass#init.
In the course of researching this question, I discovered something interesting about reopen. Even if the argument is not a mixin, it is treated as one (internally, it actually creates a temporary one). This means that if you do
Klass.reopen({
init: function() {
this._super.apply(this, arguments);
}
});
The call to super is actually calling the original init, not the init in the parent class. In other words, specifying init in a reopen does not replace the existing init on the class, it more or less layers on top of it. I can't see this behavior documented anywhere in the Ember docs, but it does seem useful in the right situation.

How can I create a class method using AppleScriptObjC

I'm trying to override the +initialize method of a class using ASOC, but I cannot find a way to override a class method. Is it even possible?
Not to let any confusion possible about the language I'm talking about, here's some code:
script FLAppDelegate
property parent: class "NSObject"
-- -- Class Methods -- --
-- Insert code here
end script
I've done some tests, and as far as I can tell, weird as it is, methods defined using AppleScriptObjC are both class and instance methods.
Let's say I have an AppleScriptObjC file:
script iTunesController
property parent: class "NSObject"
on playpause()
tell application id "com.apple.iTunes" to playpause
end playpause
end script
In an Objective-C method, both:
- (void)callASOC
{
iTunesControllerInstance = [NSClassFromString(#"iTunesController") new];
[iTunesControllerInstance playpause];
[iTunesControllerInstance release];
}
and
- (void)callASOC
{
[NSClassFromString(#"iTunesController") playpause];
}
will call the playpause handler in the AppleScriptObjC file. The latter formulation will generate a warning a compile time, but works.
I was not able to find any documentation confirming or refuting this.
Thanks to #Friziab who reminded me of the NSClassFromString
So I could call a AppleScriptObjC method in my AppDelegate.applescript from another class (script) (NSView subclass)
I don't use AppleScriptObjC so there may be a proper way of doing it but this worked
current application's NSClassFromString("AppDelegate")'s popWindow()

Creating custom CCActions for cocos2d

What is the best way to create custom actions in coco2d?
I would like to create a custom action that will create a cartoony squash animations on my game objects. Do I just subclass the CCFiniteTimeAction class and override the update method?
Any examples or links would be appreciated.
Also, within my custom action, I would like to use the CCScale action. Is that possible?
Yes that is pretty much all the magic. An example can be found at http://getsetgames.com/2009/09/23/custom-cocos2d-action-for-animating-an-atlassprites-texturerect/
It is possible to use CCScale action. I think if you import and use it it'll work just fine.
just write a custom method that returns a CCSequence
something like:
-(CCSequence)squash{
id action1=....//define action
id action2=...2nd action
...
return [CCSequence actions: action1, action2,..., nil];
}
and you just call [mySprite runAction:[self squash]];
with this solution you can change absolutely everything about the sprite (even call function inside the sequence (using CCCallFunc)
here is the link i use for documentation regarding what i can do (yes..it's written in java but there are the same methods in iphone cocos2d)
if you run into any problem..post you code and i'll look through it

Template not found in action method after calling a library method in symfony

I'm calling a method of a library that I've created in symfony 1.2. If I don't call the library method in the action method, then the method in the action class works as it should, and it finds the template. But, if I call the library method in the action class, symfony tells me that it cannot find the template associated to the action method. Any suggestions?
Did you try return sfView::NONE on your action code?
Returning sfView::NONE is telling Symfony to display nothing. The explicit return value sounds like the right approach but you probably want:
return sfView::SUCCESS;