Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/src/main/java/me/happy/demo/view/wave/WaveView3.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ protected void onDraw(Canvas canvas) {
y2 = (float) (8 * Math.sin(ω * x + φ));
mAbovePath.lineTo(x, y);
mBelowWavePath.lineTo(x, y2);
//回调 把y坐标的值传出去(在activity里面接收让小机器人随波浪一起摇摆)
mWaveAnimationListener.OnWaveAnimation(y);
}
float xCenter = (float) (getWidth()*0.5);
float yCenter = (float) (8*Math.cos(ω*xCenter+φ));
//yResult是距离view底部的距离
float yResult = getHeight() - yCenter;
mWaveAnimationListener.OnWaveAnimation(yResult);
mAbovePath.lineTo(getRight(),getBottom());
mBelowWavePath.lineTo(getRight(),getBottom());

Expand Down