Graphic rotation in J2ME 2D game development

xiaoxiao2021-03-06  18

. Graphic rotation in development in the game in J2ME game:

1. The following methods are available in the sprite of MIDP2.0:

Void

SetTransform (Int Transform)

Sets The Transform for this Sprite.

TRANS_MIRROR Causes the Sprite to appear reflected about its vertical center. Static intTRANS_MIRROR_ROT180 Causes the Sprite to appear reflected about its vertical center and then rotated clockwise by 180 degrees. Static intTRANS_MIRROR_ROT270 Causes the Sprite to appear reflected about its vertical center and then rotated clockwise by 270 degrees. static intTRANS_MIRROR_ROT90 Causes the Sprite to appear reflected about its vertical center and then rotated clockwise by 90 degrees. static intTRANS_NONE No transform is applied to the Sprite. static intTRANS_ROT180 Causes the Sprite to appear rotated clockwise by 180 degrees. static intTRANS_ROT270 Causes the Sprite To Appear Rotated ClockWise By 270 DegRees. static intectrans_rot90

It seems to be a good method: graphics can be rotated, but look back, that is, no rotation of any angle, why?

Doesn't he do not support?

Discover: from seeing sprite.java source code:

The partial rotation is 180 degrees as follows:

Case TRANS_MIRROR_ROT180:

T_collisionRecty = SrcframeHeight -

CollisionRecty CollisionRecTheight;

t_collisionRectx = CollisionRectx;

t_collisionRectwidth = CollisionRectwidth;

T_collisionRecTheight = CollisionRecTheight;

// Width and Height Are As BEFORE

THIS.WIDTH = SRCFRAMEWIDTH;

THISHEIGHT = SrcframeHeight;

// the x-offset of the reference point from the top left corner

// Remains the same.

// Top Left Y-Co-Ordinate Changes

Break;

The corresponding PAINT method:

g.drawregion (SourceImage,

FramecoRDSX [Framesequence [SequenceIndeIndex]]

Framecoordsy [framesequence [sequenceindeindex]], SRCFRAMEWIDTH,

SrcframeHeight,

T_currentTransformation,

THIS.X,

THIS.Y,

Graphics.top | graphics.Left);

The method in MIDP / Graphics also has no definition of any angle.

This DrawRegion method is defined as follows: (PS This is a native interface, but did not see the generation .h file, it seems that he is left to others)

DrawRegion

Public Void Drawregion (Image SRC, INT X_SRC, INT Y_SRC, INT Width, Int Height, Int Transform, Int X_Dest, Int Y_Dest, Int Anchor) is not disappointing or not seeing more content, it is not a way. I think that Sprite provides a multi-frame drawing function, it may be a discharier program: Think about that if you really rotate, you can call it. You don't have to rotate this sprite settransform is really a mistake. inverted. . .

转载请注明原文地址:https://www.9cbs.com/read-44100.html

New Post(0)