Bienvenue - Welcome

Vous n'êtes pas identifié(e).


Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

Deprecated: Function create_function() is deprecated in /homepages/35/d242132003/htdocs/falsam/forum/include/parser.php on line 825

#1 2016-08-24 18:05:45

falsam
Administrator
Lieu : france
Inscription : 2016-07-20
Messages : 45
Site Web

[Tuto] Game Resize

Comment réaliser un redimensionnement de votre jeu / How to make a resize of your game.

<!doctype html>
<html lang="en">
<head>
	<meta http-equiv="X-UA-Compatible" content="chrome=1, IE=edge">
	<meta charset="utf-8" />
	<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"> 
	
	<title>Game Resize</title>	
	<script src="EasySprite.js"></script>
	
	<style>
		body { background: #333; }
	</style>
</head>
<body>
	<!-- First, insert a canvas like this one -->
	<canvas id='gametest' width="100%" height="100%"></canvas>

	<!-- Now your script -->
	<script>	
	var loadProgress = 0;
	
	// A screen with the same identifier
	openScreen("gametest", 0, 0, 800, 600);
	
	// Init mouse
	initMouse();
	
	// No scroll
	document.body.style.overflow = 'hidden';
	
	// Resize and center Screen
	// Function : ResizeScreen(Center) 
	//            Center = true or false
	resizeScreen(true) 
	
	// Create and load sprite
	var square = createSprite(32, 32, "yellow", onReady)
	var demo = loadSprite("assets/image/demo.png", onReady)

	function onReady() {
		loadProgress ++;
		if (loadProgress == 2) {
			anchorSprite(square, 0.5, 0.5)
			renderGame();
		}
	}
	
	function renderGame() {
		clearScreen("rgb(255, 100, 0)");
		displaySprite(demo, 650, 550)
		
		// A Square follow a mouse
		if (mouseX() != -1) {square.x = mouseX()};
		if (mouseY() != -1) {square.y = mouseY()};	
		displaySprite(square, square.x, square.y)
		
		requestAnimationFrame(renderGame);
	}
	</script>
</body>
</html>

■ Demo : 13 - Game Resize.html

Fonctionne sur smartphone, tablette, chromebox, etc ..

Hors ligne

Pied de page des forums