Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by XLR8

Hi there, I've just recently begun using Impact and I find it to be an extremely clever programme to use when producing games. However because I’m new to the whole coding scene I was wondering if anyone could be of some assistance to me. I'm in the works of creating a game, though I would very much like to create a title screen for my game, how would I go about doing this?

I have already placed the coding required to function the title screen in my main.js, the problem is I’m not exactly sure if I've placed the pre made code in the right sections. Below is my main.js file, if any of you guys could help me it would be extremely beneficial for me.

Thank.

ig.module( 
	'game.main' 
)
.requires(
	'impact.game',
	'impact.font',
	
	'game.entities.player',
	'game.entities.SpaceMan',
	'game.entities.spike',
	'game.levels.MecoSystem'
)
.defines(function(){

MyGame = ig.Game.extend({
	
	gravity: 300, // All entities are affected by this
	
	// Load a font
	font: new ig.Font( 'media/04b03.font.png' ),
	
	
	init: function() {
		// Bind keys
		ig.input.bind( ig.KEY.LEFT_ARROW, 'left' );
		ig.input.bind( ig.KEY.RIGHT_ARROW, 'right' );
		ig.input.bind( ig.KEY.X, 'jump' );
		ig.input.bind( ig.KEY.C, 'shoot' );
		if(myGameMode == 1){
			this.loadLevel(LevelMecoSystem);
			}
		
		// Load the LevelMecoSystem as required above ('game.level.MecoSystem')
		this.loadLevel( LevelMecoSystem );
	},
	
	update: function() {		
		// screen follows the player
		var player = this.getEntitiesByType( EntityPlayer )[0];
		if( player ) {
			this.screen.x = player.pos.x - ig.system.width/2;
			this.screen.y = player.pos.y - ig.system.height/2;
		}
		
		// Update all entities and BackgroundMaps
		this.parent();
	},
	
	draw: function() {
		// Draw all entities and BackgroundMaps
		this.parent();
		
		this.font.draw( 'lEVEL 1', 2, 2 );
	}
});
Intro = ig.Class.extend({
        introTimer: null,
        font: new ig.Font( 'media/04b03.font.png' ),
        init: function() {
            this.timer = new ig.Timer(30);
        },
        run: function() {
			run:function(){
		if(myGameMode > 0){
			this.update();
			this.draw();
		}else{
			ig.system.setGame(Intro);
		}
	}
        
        if(this.introTimer.delta()<0){
            this.font.draw("INTRO MESSAGE", 100, 100, ig.Font.ALIGN.CENTER);
        }else{
            myGameMode = 1;
            ig.system.setGame(LevelMecoSystem);
			var myGameMode = 0;
        }
                    
        
        }
		
});


// Start the Game with 60fps, a resolution of 280x180, scaled
// up by a factor of 2
ig.main( '#canvas', MyGame, 60, 280, 180, 2 );

});

1 decade ago by dominic

If you want to show the Intro screen on game start, you have to call ig.main() with your Intro class, instead of your MyGame class.

Your Intro class has a some syntax errors. Check your browser's console for error messages. I'm not even sure what's it supposed to do.

1 decade ago by Jerczu

There is a tutorial called so you want to make a title screen on pointofimpactjs.com
Page 1 of 1
« first « previous next › last »