/android/LGame-Android-0.2.6S/org/loon/framework/android/game/action/sprite/SpriteMake.java

http://loon-simple.googlecode.com/ · Java · 106 lines · 61 code · 25 blank · 20 comment · 2 complexity · 7fe88b84cbda356c7232a5ebd03ba0d4 MD5 · raw file

  1. package org.loon.framework.android.game.action.sprite;
  2. import org.loon.framework.android.game.core.graphics.LColor;
  3. import org.loon.framework.android.game.core.graphics.LImage;
  4. import org.loon.framework.android.game.core.graphics.device.LGraphics;
  5. import org.loon.framework.android.game.utils.GraphicsUtils;
  6. /**
  7. * Copyright 2008 - 2009
  8. *
  9. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  10. * use this file except in compliance with the License. You may obtain a copy of
  11. * the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing, software
  16. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  17. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  18. * License for the specific language governing permissions and limitations under
  19. * the License.
  20. *
  21. * @project loonframework
  22. * @author chenpeng
  23. * @email??????ceponline@yahoo.com.cn
  24. * @version 0.1
  25. */
  26. public class SpriteMake {
  27. final static public int DOWN = 0;
  28. final static public int LEFT = 1;
  29. final static public int RIGHT = 2;
  30. final static public int UP = 3;
  31. final static public int LOWER_LEFT = 4;
  32. final static public int LOWER_RIGHT = 5;
  33. final static public int UPPER_LEFT = 6;
  34. final static public int UPPER_RIGHT = 7;
  35. private LImage shadowImage;
  36. private LImage[][] images;
  37. private int imageWidth;
  38. private int imageHeight;
  39. public SpriteMake(String fileName, int row, int col) {
  40. this.imageWidth = row;
  41. this.imageHeight = col;
  42. this.images = GraphicsUtils.getSplit2Images(fileName, row, col, false);
  43. this.images = GraphicsUtils.getFlipHorizintalImage2D(images);
  44. }
  45. public LImage makeShadowImage() {
  46. if (shadowImage == null) {
  47. shadowImage = LImage.createImage(imageWidth - imageWidth / 3,
  48. imageWidth / 2,true);
  49. LGraphics g = shadowImage.getLGraphics();
  50. g.setAlpha(0.5f);
  51. g.rectOval(0, 0, imageWidth - imageWidth / 3, imageWidth / 3,
  52. LColor.black);
  53. g.dispose();
  54. }
  55. return shadowImage;
  56. }
  57. public LImage[][] getImages() {
  58. return images;
  59. }
  60. public Sprite getMoveSprite(int index, long timer) {
  61. return new Sprite(images[index], timer);
  62. }
  63. public LImage[] getMove(int index) {
  64. return images[index];
  65. }
  66. public LImage getOnlyMove(int index) {
  67. return images[index][0];
  68. }
  69. public int getImageHeight() {
  70. return imageHeight;
  71. }
  72. public void setImageHeight(int imageHeight) {
  73. this.imageHeight = imageHeight;
  74. }
  75. public int getImageWidth() {
  76. return imageWidth;
  77. }
  78. public void setImageWidth(int imageWidth) {
  79. this.imageWidth = imageWidth;
  80. }
  81. }