Skip to content
Permalink
Browse files

storyシーン完成

  • Loading branch information
m
m committed Oct 19, 2019
1 parent d979c77 commit c69dcfb8c26b72b3ecd0a9bb0883a8b93be41927
@@ -0,0 +1,23 @@
function new_line(text, line_num){
var return_text = "";
for(var i = 0; i < text.length; i++){
if((i != 0) && (i % line_num == 0)){
return_text += "\n" + text.charAt(i);
}
else{
return_text += text.charAt(i);
}
}
return return_text;
}

//汎用配列並び替えメソッド
function sort_array(list_shuffle){
for(var i = list_shuffle.length - 1; i > 0; i--){
var r = Math.floor(Math.random() * (i + 1));
var tmp = list_shuffle[i];
list_shuffle[i] = list_shuffle[r];
list_shuffle[r] = tmp;
}
return list_shuffle;
}
@@ -143,12 +143,33 @@ phina.define('FadeOut', {
this.alpha += this.inclease_alpha;
}
else{
this.remove();
//this.remove();
main_obj.exit();
}
},
});

phina.define('FadeIn', {
superClass: 'RectangleShape',
init: function(inclease_alpha, fill_color) {
this.superInit();
this.width = SCREEN_WIDTH;
this.height = SCREEN_HEIGHT;
this.fill = fill_color;
this.alpha = 1;
this.inclease_alpha = inclease_alpha;
},
// 毎フレーム処理
update: function() {
if(this.alpha > 0){
this.alpha -= this.inclease_alpha;
if(this.alpha <= 0.1){
this.remove();
}
}
},
});

//ジャンプクラス
phina.define('OpeningJump', {
superClass: 'Sprite',
@@ -163,4 +184,36 @@ phina.define('OpeningJump', {
this.y -= 0.1;
}
},
});


//キャラクラス
phina.define('Charactor', {
superClass: 'Sprite',
init: function(file_name, inclease_alpha) {
this.superInit(file_name);
this.cnt = 0;
this.is_fadein = true;
this.is_fadeout = false;
this.inclease_alpha = inclease_alpha;
this.alpha = 0;
},
// 毎フレーム処理
update: function() {
if(this.is_fadein){
this.alpha += this.inclease_alpha;
if(this.alpha >= 1){
this.alpha = 1;
this.is_fadein = false;
}
}
if(this.is_fadeout){
this.alpha -= this.inclease_alpha;
if(this.alpha <= 0){
this.alpha = 0;
this.is_fadeout = false;
this.remove();
}
}
},
});
@@ -17,6 +17,10 @@ var ASSETS = {
'opening_button01':'src/asset/button_start01.png',
'opening_button02':'src/asset/button_start02.png',
'opening_jump':'src/asset/openning_jump.png',
'skip_button01':'src/asset/button_skip01.png',
'skip_button02':'src/asset/button_skip02.png',
'story_window':'src/asset/scenario_wnd.png',
'rin_normal':'src/asset/rin_normal.png',
},
spritesheet: {
"hit_ss":
@@ -11,13 +11,16 @@
<script src='global.js'></script>
<script src='http://cdn.rawgit.com/phi-jp/phina.js/v0.2.0/build/phina.js'></script>
<script src='question.js'></script>
<script src='scenario.js'></script>
<script src='common.js'></script>

<!-- メイン処理 -->

<script src='main.js'></script>
<script src='effect.js'></script>
<script src='quiz_main_scene.js'></script>
<script src='opening_scene.js'></script>
<script src='story_scene.js'></script>
</head>
<body>

@@ -18,16 +18,22 @@ phina.main(function() {
assets: ASSETS,
width: SCREEN_WIDTH,
height: SCREEN_HEIGHT,
fill:'black',
scenes: [
{
className: 'Opening',
label: 'opening',
nextLabel: 'story',
},
{
className: 'Story',
label: 'story',
nextLabel: 'quiz_main',
},
{
className: 'QuizMain',
label: 'quiz_main',
nextLabel: 'quiz_main',
nextLabel: 'opening',
},
]
});
@@ -190,16 +190,7 @@ function make_black(obj, w, h, a, grid_x, grid_y){
sprite.y = obj.gridY.center();
}

//汎用配列並び替えメソッド
function sort_array(list_shuffle){
for(var i = list_shuffle.length - 1; i > 0; i--){
var r = Math.floor(Math.random() * (i + 1));
var tmp = list_shuffle[i];
list_shuffle[i] = list_shuffle[r];
list_shuffle[r] = tmp;
}
return list_shuffle;
}




@@ -0,0 +1,5 @@
var list_scenario = [
"あああああああああああああああああああああああああああああああああああああああああ",
"いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい",
"ううううううううううううううううううううううううううううううううううううううう"
];
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,110 @@
var LABEL_X = 50;
var LABEL_Y = 900;
var label = "";
var scenario_line = 0;

phina.define('Story', {
superClass: 'DisplayScene',
init: function(option) {
this.superInit(option);
this.backgroundColor = 'black';
var sprite_bg = make_bg(this, 'bg', 0, 0);
var fade = make_story_fade_in(this);
setTimeout(show_story_window, 500, this);
main_obj = this;
},
});

//背景もフェードさせることで点滅回避
function make_bg(obj, sprite_name, x, y){
var bg = Charactor('bg', 0.1).addChildTo(obj);
bg.x = obj.gridX.center();
bg.y = obj.gridY.center();
return bg;
}

function show_story_window(obj){
char = make_charactor(obj);
var window = make_story_window(obj, 4);
var skip_button = make_skip_button(obj, 640, 50);
var name_label = make_name_label(obj, 60, 774, "凛太朗");
label = make_story_label(obj, LABEL_X, LABEL_Y, "");
scenario_line = next_messege(obj, scenario_line);
}

function make_story_window(obj, grid_y){
var window = Sprite('story_window').addChildTo(obj);
window.x = obj.gridX.center();
window.y = obj.gridY.center(grid_y);
window.setInteractive(true);
window.onpointend = function(e){
make_hit(obj, Number(e.pointer.x), Number(e.pointer.y));
scenario_line = next_messege(obj, scenario_line);
};
return window;
}

function next_messege(obj, num){
if(num < list_scenario.length){
text = new_line(list_scenario[num], 20);
label.text = text;
num++;
}
else{
make_story_fade_out(obj);
}
return num;
}

function make_story_label(obj, x, y, text){
var label = Label(text).addChildTo(obj);
label.x = x;
label.y = y;
label.fill = '#5a4e46'; // 塗りつぶし色
label.align = 'left';
label.lineHeight = 1.5;
return label;
}

function make_story_fade_in(obj){
var sprite = FadeIn(0.1, 'black').addChildTo(obj);
sprite.x = obj.gridX.center();
sprite.y = obj.gridY.center();
return sprite;
}

function make_charactor(obj){
var char = Charactor('rin_normal', 0.1).addChildTo(obj);
char.x = obj.gridX.center(1);
char.y = obj.gridY.center(1);
return char;
}

function make_story_fade_out(obj){
var sprite = FadeOut(0.04, 'white').addChildTo(obj);
sprite.x = obj.gridX.center();
sprite.y = obj.gridY.center();
return sprite;
}

function make_skip_button(obj, x, y){
var button = Sprite('skip_button01').addChildTo(obj);
button.x = x;
button.y = y;
button.setInteractive(true);
button.onpointend = function(e){
button.setImage('skip_button02');
make_hit(obj, Number(e.pointer.x), Number(e.pointer.y));
make_story_fade_out(obj);
};
return window;
}

//第n問ラベル作成
function make_name_label(obj, x, y, text){
var label = Label(text).addChildTo(obj);
label.x = x;
label.y = y;
label.fill = '#fedc60'; // 塗りつぶし色
return label;
}

0 comments on commit c69dcfb

Please sign in to comment.
You can’t perform that action at this time.