【发布时间】:2013-10-04 00:34:47
【问题描述】:
我正在使用Ball 在cocos3d 中开发棋盘游戏。我在touchevent 中采取了行动。我正在使用NSLog() 将位置打印到控制台。
这里是代码
-(void) touchEvent: (uint) touchType at: (CGPoint) touchPoint {
CCActionInterval *BounceAction1=[CC3MoveTo actionWithDuration:0.1 moveTo:cc3v(0.0, -5.0, -0.7)];
switch (touchType) {
case kCCTouchBegan:
[Ball runAction:BounceAction1];
NSLog(@"Location of x=%f and y=%f", Ball.globalLocation.x, Ball.globalLocation.y );
break;
}
这里,“Ball”是MeshNode。它的位置在原点cc3v(0.0, 0.0, 0.0)。
当我跑动和触球时,我发现球正在移动到指定的位置。但我得到球的位置:
Location of x=0.000000 and y=0.000000
当我再次触摸时,我发现球没有移动(因为它已经移动到指定位置)。但随后它将 Ball 的位置显示为:
Location of x=0.000000 and y=-6.000000
为什么我第一次找不到位置?
【问题讨论】:
-
因为,球的初始位置将是 (0, 0)
-
其实我的问题是,移动后我的位置也不变,即得到起始位置。
-
那你一定是在触摸你的节点着色器的子节点
-
@joshbuhler 感谢您的编辑,之后看起来不错。