我想在cocos2d-x中通过旋转实现跟踪(跟随)触摸.您可以在此处看到此效果:https://www.youtube.com/watch?v = RZouMyyNGG8(2:10).
这是我在touchMove中的代码:
_destinationX = touchPoint.x;
_destinationY = touchPoint.y;
_dx = _destinationX - draggedItem->getPositionX();
_dy = _destinationY - draggedItem->getPositionY();
_vx = _dx;
_vy = _dy;
float d = sqrtf((_dx*_dx)+(_dy*_dy));
//nice easing when near destination
if (d < 50 && d > 3){
_vx *= d / 50.0f;
_vy *= d / 50.0f;
}
else if(d <= 3){
_vx = _vy = 0;
}
draggedItem->setPosition(draggedItem->getPosition() + Point(_vx, _vy));
float rad = atan2(_dy, _dx);
float rotateTo = CC_RADIANS_TO_DEGREES(-rad); …Run Code Online (Sandbox Code Playgroud) 这是我的build.gradle文件的一部分:
android {
//...
defaultConfig {
//...
externalNativeBuild {
ndkBuild {
targets "MyGame"
arguments "NDK_MODULE_PATH=$cocospath:$cocospath/cocos:$cocospath/external:$cocospath/cocos/prebuilt-mk:$cocospath/extensions"
arguments "-j" + Runtime.runtime.availableProcessors()
buildTypes {
debug {
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
}
release {
abiFilters "armeabi"
}
}
}
}
}
//.........
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用三个abi过滤器,(armeabi, armeabi-v7a and arm64-v8a)同时在调试模式下构建应用程序,并(armeabi)在构建版本apk时仅使用一个.但它不起作用.调试版和发行版都使用了所有三个abiFilter.
我的gradle文件出了什么问题?
编辑:
事实证明,当我拥有所有三个abi过滤器并成功构建应用程序时,我想留下armeabi并且......仍然添加了所有三个.我不得不手动删除app/build目录的内容.
我从这里实现了Xiaolin Wu圆算法: https: //create.stephan-brumme.com/antialiased-circle/ in c++:
float radiusX = endRadius;
float radiusY = endRadius;
float radiusX2 = radiusX * radiusX;
float radiusY2 = radiusY * radiusY;
float maxTransparency = 127;
float quarter = roundf(radiusX2 / sqrtf(radiusX2 + radiusY2));
for(float _x = 0; _x <= quarter; _x++) {
float _y = radiusY * sqrtf(1 - _x * _x / radiusX2);
float error = _y - floorf(_y);
float transparency = roundf(error * maxTransparency);
int alpha = transparency;
int alpha2 = maxTransparency - …Run Code Online (Sandbox Code Playgroud) 我正在使用 android sdk 4.2.2 在 mac os 上创建 cocos2d-x 游戏(v. 3.4),但我也尝试了其他。我想让 NativeHelper 类从 C++ 调用一些原生的 android 东西。我使用本教程作为基础:http : //www.cocos2d-x.org/wiki/User_Tutorial-Integrate_AdMob 它正在工作,但我想使用带参数的 java 函数。并且出现错误:
02-13 09:33:20.690: W/dalvikvm(28873): 假方法描述符: (I;)V 02-13 09:33:20.690: E/JniHelper(28873): 找不到 showBanner 的静态方法 ID
这是java实现:
public static void showBanner(int position) {
final int _position = position;
_appActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
if(_appActivity != null){
if (!_appActivity.adView.isEnabled()){
_appActivity.adView.setEnabled(true);
}
if (_appActivity.adView.getVisibility() == View.INVISIBLE){
_appActivity.adView.setVisibility(View.VISIBLE);
RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
if(_position == 0){
adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
}
else{
adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); …Run Code Online (Sandbox Code Playgroud) 我有带有故事板的 swift 2.0 ios 应用程序。我有一个 tableViewController,并且在每一行中都有滚动视图(禁用用户滚动)。在这个滚动视图中,我有一个图像,它适合滚动的大小,而且有点高。事情是我想在 tableView 滚动时在该图像上实现“浮动”效果。这是一个代码:
override func scrollViewDidScroll(scrollView: UIScrollView) {
let cells = tableView.visibleCells
let offsetY = scrollView.contentOffset.y
var diff:CGFloat = (offsetY - lastY) / 10
for cell in cells {
let indexPath = tableView.indexPathForCell(cell)!
let scroll = cell.viewWithTag(102) as! UIScrollView
let oldY = scroll.contentOffset.y
let newY = oldY + diff
let height = scroll.contentSize.height
if(newY >= 0 && newY + cellHeight < height){
scroll.contentOffset = CGPointMake(scroll.contentOffset.x, newY)
}
if(indexPath.row == 0){
print("\(oldY) + \(diff) = \(newY)") …Run Code Online (Sandbox Code Playgroud) c++ ×3
cocos2d-x ×3
android ×2
android-ndk ×1
antialiasing ×1
gradle ×1
ios ×1
java ×1
ndk-build ×1
rendering ×1
swift ×1
swift2 ×1
uiscrollview ×1
uitableview ×1