android 2d 鈲設計ç¤

Download Android 2D 鈲設計ç¤

Post on 16-Apr-2017

273 views

Category:

Technology

0 download

Embed Size (px)

TRANSCRIPT

Android

Android 2D Game

Canvas ()

Android SDKViewSurfaceViewCanvas

View

1. View(GameView)

2. View.onDraw

3. OnTouchListener

4.

5. ActivityGameView

Example: Game_View

SurfaceView

1. Canvas

2.

3. UI

SurfaceView

1. SurfaceHolder.lockCanvasCanvas

2. Canvas.drawColor

3. Canvas

4. SurfaceHolder.unlockCanvasAndPost

Example: surfaceview

drawPointdrawPoints

drawLinedrawLines

drawCircle

drawArc

drawTextdrawPosText

Example: draw

(Pixel)

(Pixel)

drawPoint(float x, float y, Paint paint)

X:

Y:

Paint: Paint

(Line)

drawLine (float startX, float startY, float stopX, float stopY, Paint paint)

startXX

startYY

stopXX

stopYY

paint

https://play.google.com/store/apps/details?id=com.bitmango.flowline

(Circle)

DrawCircle(float cx, float cy, float radius, Paint paint)

Cx:

Cy:

Radius:

(Arc)

drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint)

oval :startAngle: sweepAngle: useCenter: Truepaint:

(Arc)

useCenter=false

userCenter=true

(Text)

drawText (String text, float x, float y, Paint paint)

Text:

X:

Y:

Paint:

(Bitmap)

1. Bitmap

2. Drawable.draw

Example: drawbitmap

(alpha)

AndroidRGBARedGreenBlueAlphaRGBAlpha

Paint.setAlpha

Example: alpha

Matrix.setRotate

degrees00

Example: rotate_image

(Path)

Canvas.drawPath

PathEffect

CornerPathEffectDashPathEffectPathDashPathEffectComposePathEffect

Example: image_path

Shader

BitmapShader

LinearGradient

RadialGradient

SweepGradient()

ComposeShader

Example: shader

(Frame)

25

1. XMLres/anim

2. AnimationDrawable

Example: frame

(Frame)

(Tween)

Android

Example: translate_tweenscale_tweenrotate_tweenalpha_tween

Property Animation

Android 3.0

Property Animation

1translationX translationYViewlayout00

2rotation, rotationX rotationYView

3scaleX scaleYViewpivotXpivotY

4pivotX pivotY

5x yviewtranslationXtranslationY

6aplha10

XML

XML

XML

propertyNameget/set

duration

valueFrom valueToTranslation

repeatCountrepeatMode

Example:View_anim

property_anim

Contact

E-mail: pinglunliao [at] gmail [dot] com

LINE: Holan.Liao

Skype: pinglunliao

FB: https://www.facebook.com/LiaoPingLun