/android/Android(LGame-0.3.2&LAE-1.1)/LGame-0.3.2(OpenGLES)/src/core/org/loon/framework/android/game/action/sprite/Mask.java

http://loon-simple.googlecode.com/ · Java · 81 lines · 41 code · 17 blank · 23 comment · 6 complexity · d70e2581eadf9fb788875bd919a5ba0e MD5 · raw file

  1. package org.loon.framework.android.game.action.sprite;
  2. import java.io.Serializable;
  3. import org.loon.framework.android.game.core.LRelease;
  4. /**
  5. * Copyright 2008 - 2011
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  16. * either express or implied. See the License for the specific language
  17. * governing permissions and limitations under the License.
  18. *
  19. * @project loonframework
  20. * @author chenpeng
  21. * @email?ceponline@yahoo.com.cn
  22. * @version 0.1
  23. */
  24. public class Mask implements Serializable, LRelease {
  25. /**
  26. * ?????????
  27. */
  28. private static final long serialVersionUID = -4316629891519820901L;
  29. private int height;
  30. private int width;
  31. private boolean[][] data;
  32. public Mask(int width, int height) {
  33. this.width = width;
  34. this.height = height;
  35. }
  36. public Mask(boolean[][] data, int width, int height) {
  37. this.data = data;
  38. this.width = width;
  39. this.height = height;
  40. }
  41. public boolean[][] getData() {
  42. return data;
  43. }
  44. public boolean getPixel(int x, int y) {
  45. if (x < 0 || x >= width || y < 0 || y >= height) {
  46. return false;
  47. }
  48. return data[y][x];
  49. }
  50. public void setData(boolean[][] data) {
  51. this.data = data;
  52. }
  53. public int getWidth() {
  54. return width;
  55. }
  56. public int getHeight() {
  57. return height;
  58. }
  59. public void dispose() {
  60. if (data != null) {
  61. data = null;
  62. }
  63. }
  64. }