Wednesday, December 28, 2011

Abstract Class in AS3 - How To

Here is a hack for making an class that will function as an abstract class:
Cut and paste code below:
3 Files in code below:
[1]: The Base Abstract Class
[2]: The Sub Class that Extends the Abstract Class
[3]: .FLA file testing it.

ABSTRACT CLASS CODE:_________________________________________________

package com.JMIM02.ABS_TestAbstract{
    //Class Summary:
    //A test to see if I can make a TEST abstract class by simply throwing an ERROR in the constructor
    //Of the class that is an abstract class. Would only work if you DON'T need to call the superMethod
    //When using a class that extends this class.
    public class ABS_TestAbstract{

        protected var testVar:Number = 77;

        public function ABS_TestAbstract() {
        protected function overrideToEmpty():void{
            throw new Error("Abstract Class Cannot be instantiated by itself");


SUPERCLASS/SUBCLASS/DERIVED CLASS CODE:_______________________________

package com.JMIM02.Uses_TestAbstract{
    //Class Summary:
    //A test class that tests if I can make a "Pseudo Abstract Class"
    //By making the Base-Class's constructor throw an error.
    //This would prevent the class from being directly instantiated.
    import com.JMIM02.ABS_TestAbstract.ABS_TestAbstract;
    public class Uses_TestAbstract extends ABS_TestAbstract {

        public function Uses_TestAbstract() {
            testVar = 333;
            trace("testVar===" + testVar);
        //make an empty function so that you can instantiate the base-class.
        protected override function overrideToEmpty():void{}//[x]

.FLA FILE TESTING CLASS:______________________________________________

import com.JMIM02.Uses_TestAbstract.Uses_TestAbstract;
import com.JMIM02.ABS_TestAbstract.ABS_TestAbstract;

var inst:Uses_TestAbstract = new Uses_TestAbstract();

//block of code below WILL throw error since you cannot directly instance the base-class:
var base:ABS_TestAbstract = new ABS_TestAbstract();

Monday, December 26, 2011

Chain Reaction Proof Of Concept for Asteroids Game

After I make my simple asteroids game with a twist... It would be cool to make
a game with a style like this but using the same chain-reaction concept:

On an unrelated note: I like this game's loading screen:

I like this game design for it's simplicity and ease to create:

Saturday, December 24, 2011

Collision Physics For My Asteroids Game Working!

I went on a rather large side-quest of coding some max-script for money.
And then I got distracted by deciding to work on UI elements instead of game
physics since game physics was wearing me down. I took another crack at my
physics over the past few days and now I have what I what I believe to be a fairly
acceptable collision manager that resolves collisions in an elastic manner.

Friday, December 23, 2011

Menu Button Class AS3, with arrow control

I feel like I've been working on this TOO long. But I thought an approach of
working on UI stuff FIRST, and then the game-content might help me organization-wise. I think the next step here is to make a "mock-game"
like "CowClicker". Something really simple where all the basics are in place.

menuButton Class Code

Internally: I call this class:
Does NOT yet have arrow controls in it.
Also, will glitch out if you slide the cursor over the button REALLY FAST
when the app is first initialized. Fixed in latest version.