- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在检测到触摸后立即放大按钮。这是我的场景:
@implementation HomeScene
-(id) init
{
if((self = [super init])) {
...
// sp_btn_story is retained...
sp_btn_story = [[CCSprite spriteWithFile:@"main_menu_btn.png"] retain];
sp_btn_story.position = ccp(size.width - 146, 110);
[self addChild: sp_btn_story];
...
}
return self;
}
-(void) onEnter
{
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
}
-(void) onExit
{
[[CCTouchDispatcher sharedDispatcher] removeDelegate:self];
}
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
NSLog(@"tapped!");
sp_btn_story.scaleX = 2;
[sp_btn_story stopAllActions];
[sp_btn_story runAction: [CCScaleTo actionWithDuration:0.5f scale:1.2f]];
return YES;
}
...
@end
正如预期的那样,它很好地缩放了 X。 (我把它放在那里进行测试。)但是由于某种原因该操作没有运行。 :( 有人有什么想法吗?
编辑:使用 cocos2d 0.99 顺便说一句。
最佳答案
此问题的答案(从提问者自己的评论中重新发布,以使其更加明显):
It's quite important to call
[super onEnter];
if you overwrite this method in a subclass or strange things may happen. Cocos2D will not be happy.
This applies to other (if not all) methods as well, e. g. always call
[super onExit];
as well.
关于iphone - Action 不会在 iPhone 版 cocos2d 中的 ccTouchBegan 中的 CCSprite 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2353774/
更新 我改成了更简单的例子 好吧,现在我真的很困惑我简化了类,因为我在网上阅读建议是扩展 CCNode 比 CCSprite 更好并将其保留为 CCNode 的成员所以这是基于 Hello cpp 的
我正在尝试让我的 CCLayer 子类响应多点触控。在我调用的 init 方法中 self.isTouchEnabled=YES; 在一个名为 registerWithTouchDispatcher
我试图在检测到触摸后立即放大按钮。这是我的场景: @implementation HomeScene -(id) init { if((self = [super init])) { ..
我是一名优秀的程序员,十分优秀!