<p>Hi there! I made a post a couple of days ago asking a question about changing background colors on touch events in Android:
<a href="https://www.reddit.com/r/golang/comments/84ovyk/making_a_simple_go_android_app/">https://www.reddit.com/r/golang/comments/84ovyk/making_a_simple_go_android_app/</a></p>
<p>I've been googling around to find out how to make the background color change, but have not been in luck yet.
I was wondering if someone could take a look at my code and help me figure out why it's not working the way I want to. The only function the app should have is to change background colors on screen touch.
The code:
<a href="https://pastebin.com/TxFweAP9">https://pastebin.com/TxFweAP9</a></p>
<p>Any feedback will be greatly appreciated.</p>
<hr/>**评论:**<br/><br/>MonkeeSage: <pre><p>Because <code>OnPaint</code> is being called from a tight loop that triggers itself:</p>
<pre><code> onPaint(glctx, sz)
a.Publish()
// Drive the animation by preparing to paint the next frame
// after this one is shown.
a.Send(paint.Event{})
</code></pre>
<p>And then <code>OnPaint</code> resets the color:</p>
<pre><code>glctx.ClearColor(0, 0, 1, 1)
</code></pre>
<p>Change <code>OnPaint</code> to only do this and it should work:</p>
<pre><code>func onPaint(glctx gl.Context, sz size.Event) {
glctx.Clear(gl.COLOR_BUFFER_BIT)
}
</code></pre></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传