Coder Social home page Coder Social logo

as3-cheats's Introduction

AS3 Cheats

This library provides an easy way to handle cheats within flash. Register a key combination or phrase to a cheat and it gets then triggered by the library.

Use cases for this library:

  • Enable functionalities in live environments which should be normally deactivated (e.g. logging)
  • Use cheats within games
  • Trigger easter eggs

Dependencies

This library is compiled against as3-signals-v0.7. The swc is included in the download file. More information regarding as3-signals can be found here.

Usage

Creation

First of all you have to initialize the CheatLib with the stage and a custom identifier:

var lib:ICheatLib = CheatLib.create(stage, "demo");

You can then either use the returned instance or always retrieve it via the CheatLib.get(id).

Basic usage

The basic use-case is to enter a string and then trigger a functionality.

CheatLib.get("demo")
	.createCheat("test")
		.toggledSignal
		.add(handleTestCheatToggle);

function handleTestCheatToggle(cheat:ICheat):void
{
	trace("Test cheat toggled, now " + cheat.activated);
}

You can always get the created cheat again via the getCheat() method:

CheatLib.get("demo")
	.getCheat("test");

Master cheats

With master cheats you block certain cheats until the master is activated. This would be the easiest way to just use one master cheat:

CheatLib.get("demo")
	.createMasterCheat("master");

A more complex example, on how to use multiple master cheats will follow later.

Persistency

If you don't want to re-enter you cheats after each restart you can use the optional persistent flag. It stores the cheat state in the LocalSharedObject and re-initializes it on the next start. This flag needs to be set for each cheat individually.

CheatLib.get("demo")
	.createMasterCheat("master", true);

Complex cheat codes

For more advanced cheat codes โ€“ including special keys โ€“ you can use the following syntax:

CheatLib.get("demo")
	.addCheat(CheatBuilder.create("fps", 
				CheatCodeBuilder.create()
					.appendKeyCode(Keyboard.ENTER)
					.appendString("fps")
					.appendKeyCode(Keyboard.ENTER)
					.build())
				.build());

In this case the cheat code consists of "Enter" + "fps" + "Enter".

For more insight please check out the example implementation.

Change log

0.0.1 (2011/07/07)

  • [Added] Cheat functionality for any combination of strings and special keys
  • [Added] Cheats can be toggled (on/off)
  • [Added] Per cheat and global toggled Signal
  • [Added] Master Cheat support
  • [Added] Cheats can be optionally persisted (Local Shared Object)
  • [Added] Static access for easy access (CheatLib.get(id))

Roadmap

  • Default debug output for cheat toggle

as3-cheats's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.