1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.replica.replicaisland; 18 19/** 20 * Implements a bitmap that can be scrolled in place, such as the background of a scrolling 21 * world. 22 */ 23public class ScrollableBitmap extends DrawableBitmap { 24 private float mScrollOriginX; 25 private float mScrollOriginY; 26 27 public ScrollableBitmap(Texture texture, int width, int height) { 28 super(texture, width, height); 29 } 30 31 public void setScrollOrigin(float x, float y) { 32 mScrollOriginX = x; 33 mScrollOriginY = y; 34 } 35 36 @Override 37 public void draw(float x, float y, float scaleX, float scaleY) { 38 super.draw(x - mScrollOriginX, y - mScrollOriginY, scaleX, scaleY); 39 } 40 41 public float getScrollOriginX() { 42 return mScrollOriginX; 43 } 44 45 public void setScrollOriginX(float scrollOriginX) { 46 mScrollOriginX = scrollOriginX; 47 } 48 49 public float getScrollOriginY() { 50 return mScrollOriginY; 51 } 52 53 public void setScrollOriginY(float scrollOriginY) { 54 mScrollOriginY = scrollOriginY; 55 } 56} 57