问题描述
发生了什么事codeNAME一个动画?我用了很多他们与截至12月我的应用程序不再工作。当我离开的事情在六月一切都很好(并且是因此对于超过一年)。
What happened to Codename One animations? I use a lot of them and as of december my app is no longer working. When I left things in June everything was fine (and was so for more than a year).
我的应用程序是一个草稿(跳棋)游戏,在应用程序商店提供2013年以来看到CN1扑克演示之后,我完全重写我的GUI,因为我想对那些样的动画添加到我的应用程序。现在是什么情况是,我突然得到指数走出束缚异常。我这个缩小到以下情况:
My app is a draughts (checkers) game and is available in the app stores since 2013. After seeing the CN1 Poker demo, I completely rewrote my GUI as I wanted to add those kind of animations to my app. What happens now is that I suddenly get index out of bound exceptions. I narrowed this down to the following situation:
cont.addComponent(comp);
...
...
cont.getComponent(0); <-- index out of bound exception: 0 out of 0
我已经用newvm的=真六月,也就是现在的默认,我相信。我试图通过增加一个
I already used newVM=true in June, which is now the default, I believe. I tried to fix things by adding a
cont.animateLayoutAndWait(100);
在addComponent调用之后。这种固定索引出界的例外,但现在的应用只是很短的时间工作的罚款后随机瞬间崩溃。我试过,但一直无法找到问题的根源。东西CN1发生了变化,使我的code不再起作用。 (另见老论坛,搜索草稿,在这里我贴我的基本设计的完整列表。)
after the addComponent call. This fixed the index out of bound exceptions, but now the app just crashes at random moments after working fine for a short time. I tried but have been unable to find the source of the problem. Something has changed in CN1 so that my code no longer works. (See also the old forum, search for "draughts", where I posted a complete listing of my basic design.)
我研究了新接龙演示,其中有大部分的动画功能,我需要。和接龙的应用程序商店的版本上运行所有的iOS我/ Android设备的罚款。 A小调错误是可以拖动卡组包括一些朝下,这是在拖动操作期间朝上。此外,它是pretty很难拿起正好卡各适量。拖动一组卡也离开屏幕,这看起来并不很漂亮的白色痕迹。这也发生在模拟器。
I studied the new Solitaire demo, which has most of the animation functionality I need. And the app store versions of Solitaire run fine on all my iOS/Android devices. A minor bug is that it is possible to drag a group of cards including some that are facing down, which are facing up during the drag operation. Also it is pretty hard to pick up exactly the right amount of cards. Dragging a group of cards also leaves a white trail on the screen, which doesn't look very nice. This also happens in the Simulator.
作为一个实验,我重新设计了我的GUI布局恰好类似的接龙code的:按键两层,唯一的区别是,我使用GridLayout的(10,10),其中接龙使用SolitaireLayout()。这工作,除了一件事:如果检查下移它正确地移过其他跳棋板,但如果检查向上移动板它移到其他跳棋在
As an experiment, I redesigned my GUI layout to exactly resemble that of the Solitaire code: two layers of buttons, the only difference being that I use GridLayout(10,10) where Solitaire uses SolitaireLayout(). This works, except for one thing: if a checker moves DOWN the board it correctly moves OVER other checkers, but if a checker moves UP the board it moves UNDER the other checkers.
我的code是这样的:
My code looks like this:
Button pc = (Button)piecesCnt.getComponentAt(a1);
Button to = (Button)piecesCnt.getComponentAt(a2);
piecesCnt.removeComponent(pc);
piecesCnt.addComponent(a1, createPieceButton(Piece.EMPTY_PIECE, true));
piecesCnt.removeComponent(to);
piecesCnt.addComponent(a2, pc);
piecesCnt.animateLayoutAndWait(1000);
如此看来,这些按钮在他们的网格布局顺序总是绘制,而我希望动画(移动)按钮将最后绘制/在上面,就像纸牌移动卡。
So it seems that the buttons are always drawn in their GridLayout order, while I hoped that the animated (moving) button would be drawn last/on top, just like the moving cards in Solitaire.
这是在SolitaireLayout处理动画与网格布局之间的差异?如果是这样,这可以在动画逻辑改变?否则,我必须添加额外的动画层和大量的开销。
Is this a difference between handling animation in SolitaireLayout vs. GridLayout? If so, can this be changed in the animation logic? Otherwise I have to add an extra animation layer and a lot of overhead.
和Android上,动画(运动)不能正常工作。所以我决定也自我构建和测试在我的当前版本CN1设备(3.2.6插件,库2016年1月11日)的纸牌演示。我改变了动画要慢10倍,更清楚地看到发生了什么。在仿真,布局和动画工作大多不错,但在我的iOS和Android设备有很多的问题。
And on Android, the animation (movement) is not working properly. So I decided to also self-build and test the Solitaire demo on my devices with the current CN1 version (plugin 3.2.6, libs 2016-01-11). I changed the animations to be 10x slower, to better see what is happening. In the Simulator, the layout and animations work mostly fine but on my iOS and Android devices there are a lot of problems.
仿真器(Windows 7中的NetBeans 8.0.2):
- 我用文字代替的字体图标,因为它们丢失。
- 但是如何访问汉堡菜单?我没有看到3点,甚至有没有空间了。
- 有时也能够拖动一组卡采取了一些downfacing卡;而拖着他们暂时翻转朝上。
- 自动播放并不总是似乎工作。 (不是所有的动作玩法。)
Simulator (Windows 7, NetBeans 8.0.2):- I replaced the font icons by text since they are missing.- But how to access the hamburger menu? I don't see the 3 dots and there is even no space for it.- Sometimes it is possible to drags a groups of cards with some downfacing cards taken; while dragged they are temporarily flipped facing up.- Autoplay doesn't always seem to work. (Not all moves are played.)
在iOS 9.2(iPad的4)的iOS 8.4(iPhone 4):
- 显示在汉堡包菜单复选框[?]。
- 启动后,画面背景卡背上跳到容器/屏幕的底部。
- 有时候,在这笔交易中,从甲板动画,在最右边的画面卡暂时面朝上,卡已经朝上翻转都朝下。最终的交易状态是正确的,但是。
- 撤销/重做:有时会出现在甲板上0对置开门卡和甲板上1面朝下。
- 有时重做跳到新的布局,而不是动画。
只有iPhone:
- 自动播放动作序列中留下了不一致的基础状态:顶级卡片心脏-J,俱乐部-10,俱乐部-K,钻石-Q;即,在不同的基础2俱乐部卡堆。
On iOS 9.2 (iPad 4), iOS 8.4 (iPhone 4):- [?] is shown in the hamburger menu check boxes.- After startup, the tableau background card-backs jump to the bottom of the container/screen.- Sometimes, in the deal-from-deck animation, cards in the rightmost tableau are temporarily facing up, and cards already facing up are flipped facing down. The final deal-state is correct, however.- Undo/Redo: sometimes results in a facing-up card on deck 0 and a facing-down on deck 1.- Redo sometimes 'jumps' to the new layout instead of animating.iPhone only:- A sequence of autoplay moves left an inconsistent foundation state: top cards heart-J, club-10, club-K, diamond-Q; i.e., 2 club-cards on different foundation stacks.
在Android 5.1.1(的Nexus 7)还有更多的问题。
- 该协议,从甲板动画是不是pretty视线。卡被插入在画面栈的底部(滑动),因此,它们在其他卡滑动。移动卡应朝下,但通常是朝上的,总是表示第一张牌到画面1.画面最右边的卡暂时朝上。最后,已经面临了卡片翻转朝下,然后再返回。最终的交易状态是正确的,但是。
- 自动播放也没有当有连续几个动作纠正。在动画,一些基础卡正面朝上改变自己的卡值(前)暂时。也移动卡的基础卡下滑动(有时超过,但是这是例外)。
- 完成游戏后,做得好的屏幕损坏,因为文本似乎显示不重叠,但低于卡(在一个大的白色空间),这是只有在屏幕的顶部一小部分若隐若现。
- 因为交易 - 从甲板未启动开始一个新的游戏经常会失败;屏幕显示甲板和与画面空地基四大天王。当攻甲板上,一个张牌并出色地完成序列展。有时重复这导致成功启动一个新游戏。
On Android 5.1.1 (Nexus 7) there are more problems.- The deal-from-deck animation is not a pretty sight. Cards are inserted (slide to) at the bottom of the tableau stacks, so they slide under the other cards. The moving cards should be facing down but are usually facing up, always showing the first card dealt to tableau 1. The cards in rightmost tableau are temporarily facing up. Finally, cards already facing up are flipped facing down and back again. The final deal-state is correct, however.- Autoplay is also not correct when there are several moves in a row. During the animations, several foundation cards facing up change their card value (front) temporarily. Also the moving cards slide under the foundation card (and sometimes over, but this is the exception).- After finishing the game, the well-done screen is corrupted since the text seems to be displayed not overlayed but below the cards (in a big white space), which are only partly visible in a tiny portion at the top of the screen.- Starting a new game often fails because deal-from-deck is not started; the screen shows a deck and four kings on the foundations with the tableau empty. When tapping the deck, a card is dealt and the well done sequence is show. Sometimes repeating this results in successfully starting a new game.
这一切都已经采取了大量的时间已经和我还没有我的应用程序重新工作,这是非常令人沮丧的。有这么多的麻烦,这个话题,即使下载的演示程序,建立这种类型与codeNAME应用的一个感觉就像建立在流沙。请帮助!
All this has taken a lot of time already and I still don't have my app working again, which is very frustrating. Having so much trouble with this topic, even with a downloaded demo app, building this type of app with Codename One feels like building on quicksand. Please help!
推荐答案
您应该可能只是问,一旦你遇到了麻烦,而不是对后这么辛苦的工作。是的,我们的确作出重大有点破的兼容性变化作为长期动画问题的bug修复(如并行运行的动画能碰撞)的一部分。
You should have probably just asked once you ran into trouble instead of working so hard on the post. Yes we did make a major somewhat compatibility breaking change as part of a bug fix for long standing animation issues (where animations running in parallel could collide).
这引入了一些碰撞,但设备之间的不一致减少/模拟器这始终是一件好事。
This introduced some collisions but reduced inconsistencies between devices/simulator which is always a good thing.
我们宣布这个位置:
这实际上是要简单得多,现在创建一个便携式动画作为一切都将得到同步,以避免碰撞的动画例如如果你这样做 Component.removeComponent()
,而动画过程中它会被默认添加到队列动画并进行了动画立即完成,而不是之后。
It is actually MUCH simpler to create a portable animation now as everything will get synchronized to avoid animation collisions e.g. if you do Component.removeComponent()
while an animation is in progress it will be implicitly added to the animation queue and performed after the animation completes instead of immediately.
要推迟你的下一个动作,直到动画后,我们有:
To postpone your next action until after the animations we have:
form.getAnimationManager().flushAnimation(() -> doThisAfterAnimation());
更简单,无特殊情况下,全局锁。
Much simpler and no special case global locks.
它有点难以端口code直接到新的方法,但它看起来像你的动画逻辑依赖于动画拍摄1000毫秒,它彻底完蛋了在方法返回时可能并不总是如此(如添加/删除通话或其它逻辑可能的方式获得)。
Its a bit hard to "port" code directly to the new approach but it looks like your animate logic relies on the animation taking 1000ms and that it completely finished when the method returns which might not always be the case (as add/remove calls or other logic might get in the way).
在过去,以保证动画的唯一方法是完全是分开距离他们,但现在你只需要使用 flushAnimation
,以确保所有的动画完成。请记住,有些事情是没有明确的动画现在可以成为意外例如动画在添加/删除组件将成为动画,如果有正在进行的动画,当你打电话给他们...
In the past the only way to guarantee an animation was complete was to distance them apart but now you can just use flushAnimation
to make sure all animations have completed. Keep in mind that some things that aren't explicitly an animation can now become an animation by accident e.g. an add/remove component will become an animation if there is an animation in progress when you call them...
这篇关于codeNAME一个动画麻烦(也接龙演示)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!