Android Open Source - smoke-or-fire Surface View






From Project

Back to project page smoke-or-fire.

License

The source code is released under:

GNU General Public License

If you think the Android project smoke-or-fire listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 *  Copyright 2012 Brian Flores//from  ww  w .  ja v a2s  .  com
 *
 *  This file is part of SmokeOrFire.
 *
 *  SmokeOrFire is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  SmokeOrFire is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with SmokeOrFire.  If not, see <http://www.gnu.org/licenses/>.
 */

package net.votebrian.games.sof;

import android.util.AttributeSet;
import android.content.Context;
import android.view.MotionEvent;
import android.opengl.GLSurfaceView;

public class SurfaceView extends GLSurfaceView {

    int EVENT_DOWN = 0;
    int EVENT_MOVE = 1;
    int EVENT_UP   = 2;

    private GLESRenderer renderer;

    float mStartX = 0;
    float mStartY = 0;

    public SurfaceView(Context context, AttributeSet atr) {
        super(context, atr);
        renderer = new GLESRenderer(context);

        setRenderer(renderer);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        int action = event.getAction();
        float x = event.getX();
        float y = event.getY();

        if(Global.getReady()) {
            switch(action) {
                case MotionEvent.ACTION_DOWN:
                    renderer.buttonEvent(x, y, EVENT_DOWN);
                    break;

                case MotionEvent.ACTION_UP:
                    renderer.buttonEvent(x, y, EVENT_UP);
                    break;

                case MotionEvent.ACTION_MOVE:
                    renderer.buttonEvent(x,y, EVENT_MOVE);
                    break;
            }
        }

        return true;
    }

    @Override
    public void onPause() {
        super.onPause();
        renderer.onPause();
    }
}




Java Source Code List

net.votebrian.games.sof.AboutActivity.java
net.votebrian.games.sof.Base64DecoderException.java
net.votebrian.games.sof.Base64.java
net.votebrian.games.sof.Btn.java
net.votebrian.games.sof.Buttons.java
net.votebrian.games.sof.Card.java
net.votebrian.games.sof.Deck.java
net.votebrian.games.sof.GLESRenderer.java
net.votebrian.games.sof.Global.java
net.votebrian.games.sof.IabException.java
net.votebrian.games.sof.IabHelper.java
net.votebrian.games.sof.IabResult.java
net.votebrian.games.sof.Inventory.java
net.votebrian.games.sof.Labels.java
net.votebrian.games.sof.Model.java
net.votebrian.games.sof.PassButton.java
net.votebrian.games.sof.PurchaseActivity.java
net.votebrian.games.sof.Purchase.java
net.votebrian.games.sof.Security.java
net.votebrian.games.sof.SkuDetails.java
net.votebrian.games.sof.SoFActivity.java
net.votebrian.games.sof.SurfaceView.java
net.votebrian.games.sof.TutorialActivity.java