Path.offset()不工作的每个设备上 [英] Path.offset() not working on every device

查看:188
本文介绍了Path.offset()不工作的每个设备上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题android.graphics.path。结果
我正在开发一个游戏。我有一些路径。他们不改变有大小,形状。我画他们到画布上。我谨他们在每场比赛的框架。所以我设置的偏移:DX

I have some problems with android.graphics.path.
I am developing a game. I have some Paths. They don't change there sizes, shapes. I draw them onto a canvas. I move them in every game's frame. So I set an offset: dx

它工作正常,在许多设备上:

It works fine on many devices:


  • 诺基亚个双SIM(Android版4.4.4 Cyanogenmode)(API级别19)

  • 三星Galaxy二重奏(GT-S7562)(Android的4.0.4)(API级别15)

  • 索尼X8(Android版2.3.7 Cyanogenmode)(API 10级)

  • 和其他一些

但它没有效果很好的一些其他设备:

But it not works well on some other devices:


  • 三星Galaxy王牌II(Android版4.1.2)(API级别16)

  • 诺基亚个双SIM(诺基亚X平台1.2)(Android Studio中显示:原料药16级)

  • 和一些其他
    我设置我的画法偏移量:

  • Samsung Galaxy Ace II (Android 4.1.2)(API level 16)
  • Nokia X Dual Sim (Nokia X platform 1.2)(Android Studio shows: API level 16)
  • and on some others I set the offset in my draw method:

path.offset(DX,0);

path.offset(dX, 0);

不工作的手段:它没有移动。该系统它绘制到原来的位置。结果,
但是,当它的工作原理,它的工作原理血统(移动,速度快)

Not working means: it not moves. The system draws it to the original position.
But when it works, it works descent (moves, and it is fast)

我也试图与矩阵:

translateMatrix = new Matrix();
translateMatrix.setTranslate(dX, 0);
path.transform(translateMatrix);

同样的事情发生。

The same happened.

我看到的Andr​​oid开发者网站的内容:
http://developer.android.com/reference/android/graphics/Path.html 结果
无效偏移(DX浮球,浮球DY)结果
抵消(DX,DY)的路径,成功返回true。结果
???它必须有所改变,这就是为什么这里是一个错误

I see something on developer site of Android: http://developer.android.com/reference/android/graphics/Path.html
void offset(float dx, float dy)
Offset the path by (dx,dy), returning true on success.
??? It must have changed, that's why here is an error

这可能与硬件连接方式加速:结果
https://groups.google.com/forum/#​​!topic/android -developers / HgGVSbSghpk 结果

It may in connection with the Hardware Accelerated mode:
https://groups.google.com/forum/#!topic/android-developers/HgGVSbSghpk

我从API级9的支持,但我转身Harware加速模式。 (它的工作原理形式API级别14)结果
这个问题也表明了,当我把它关掉。结果
我不明白为什么它有时超过API 14级的工作,有时为什么不呢?结果

I support from Api level 9, but I turned Harware Accelerated mode. (It works form API level 14)
The problem also shows up when I turn it off.
I don't see why is it sometimes work over API level 14, and sometimes why not?

它说,硬件加速模式支持路径:结果
http://android-developers.blogspot.de/2011/03/android-30-hardware-acceleration.html

It says, hardware accelerated mode supports Path:
http://android-developers.blogspot.de/2011/03/android-30-hardware-acceleration.html

你知道这有什么问题吗?我应该怎么办?

Do you know what is the problem with this? What should I do?

东西混合起来更多:
此工程每一个设备上(但速度较慢的作品 - 它落后于):

Something that mixes it up more: This works on every device (but works slower - it lags):

Canvas temp = new Canvas(bitmap);
path.draw(temp);
originalCanvas.drawBitmap(bitmap, 0, 0, myPaint);

所以


  1. 我做一个临时的帆布

  2. 我把它放在一个位图

  3. 我绘制画布上(这将是对位图)

  4. 我绘制位图到原来的帆布

为什么在这里工作?

请帮助我,我应该怎么使它工作。

Please help me how should I make it work.

推荐答案

我做了工作,但不能与偏移

I made it work, but not with the offset

我做我自己的偏移功能:

I made my own offset function:


  1. 它保存的最后位置,并计算新的使用
    抵消。

  2. 然后创建一个新的路径,而无需使用new运算符

  1. it saves the last position, and calculates the new one with the offset.
  2. Then it creates a new Path without using operator new

calculateNewPoints();结果,
wallpath.rewind();结果
wallpath.moveTo(newPosX,newPosY);结果
。结果
。结果
。结果
wallpath.close();

calculateNewPoints();
wallpath.rewind();
wallpath.moveTo(newPosX, newPosY);
.
.
.
wallpath.close();

这表现良好:)

这篇关于Path.offset()不工作的每个设备上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆