Skip to content
Permalink
Browse files

label生成の統一

  • Loading branch information
m
m committed Oct 25, 2019
1 parent 4e0f6d4 commit 6e73d1f099c538996794ab5943597f7c773d66e4
Showing with 74 additions and 70 deletions.
  1. +44 −0 common.js
  2. +12 −3 global.js
  3. +6 −2 local_index.html
  4. +4 −48 quiz_main_scene.js
  5. +3 −2 share_scene.js
  6. +5 −15 story_scene.js
@@ -57,6 +57,50 @@ function add_zero(num){
}
}

//黒背景作成
function make_black(obj, w, h, a, grid_x, grid_y){
var rect = RectangleShape({
width:w,
height:h,
strokeWidth:0,
fill:'back',
cornerRadius:10
}).addChildTo(obj);
rect.x = obj.gridX.center(grid_x);
rect.y = obj.gridY.center(grid_y);
rect.alpha = a;
return rect;
}


//汎用スプライト作成メソッド
function make_sprite(obj, sprite_name, x, y){
var sprite = Sprite(sprite_name).addChildTo(obj);
if((x == 0) && (y == 0)){
sprite.x = obj.gridX.center();
sprite.y = obj.gridY.center();
}
else{
sprite.x = x;
sprite.y = y;
}
return sprite;
}

//汎用ラベル作成メソッド
function make_label(obj, text, line_num, x, y, fill_color, font_size){
text = new_line(text, line_num);
var label = Label(text).addChildTo(obj);
label.x = x;
label.y = y;
label.fill = fill_color;
label.align = 'left';
if(font_size != null){
label.fontSize = font_size;
}
return label;
}

function play_se(se_name){
if(IS_LOCAL) return null;
try {
@@ -1,10 +1,13 @@
var IS_LOCAL = true;
var IS_LOCAL = false;

//出題問題数
var FINISH_QUESTION_NUMBER = 3;
//合格問題数
var CLEAR_QUESTION_NUMBER = 1;

var VERSION = "1.0.1.0";
var SCREEN_WIDTH = 750;
var SCREEN_HEIGHT = 1334;
var FINISH_QUESTION_NUMBER = 3;
var CLEAR_QUESTION_NUMBER = 1;
var question_number = 0;
var char;
var correct_num = 0;
@@ -15,6 +18,12 @@ var sound_path = "";
var is_clear = false;
var main_obj;

//story
var LABEL_X = 50;
var LABEL_Y = 900;
var label = "";
var scenario_line = 0;

var url_16 = "";
var url_19 = "";

@@ -10,10 +10,14 @@
<link href="./src/css/css/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="./src/css/js/bootstrap.min.js"></script>

<script src='global.js'></script>
<script>
$(function(){
IS_LOCAL = true;
});
</script>
<title>テスターちゃんレベル試験</title>
<!-- phina.js を読み込む -->
<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>
@@ -33,36 +33,8 @@ function init_global_value(){
is_tap_ok = false;
}

//黒背景作成
function make_black(obj, w, h, a, grid_x, grid_y){
var rect = RectangleShape({
width:w,
height:h,
strokeWidth:0,
fill:'back',
cornerRadius:10
}).addChildTo(obj);
rect.x = obj.gridX.center(grid_x);
rect.y = obj.gridY.center(grid_y);
rect.alpha = a;
return rect;
}


//汎用スプライト作成メソッド
function make_sprite(obj, sprite_name, x, y){
var sprite = Sprite(sprite_name).addChildTo(obj);
if((x == 0) && (y == 0)){
sprite.x = obj.gridX.center();
sprite.y = obj.gridY.center();
}
else{
sprite.x = x;
sprite.y = y;
}
return sprite;
}

//問題取得
function get_question(){
return use_question_db.pop();
@@ -105,31 +77,19 @@ function make_black(obj, w, h, a, grid_x, grid_y){
var question_window = Sprite('question_window').addChildTo(group);
question_window.x = obj.gridX.center();
question_window.y = y;
text = new_line(text, 20)
var label = Label(text).addChildTo(group);
label.x = LABEL_X;
label.y = y;
label.fill = '#5a4e46'; // 塗りつぶし色
label.align = 'left';
var label = make_label(group, text, 20, LABEL_X, y,'#5a4e46');
}

//第n問ラベル作成
function make_question_number_label(obj, group, y, number){
text = "" + number + ""
var label = Label(text).addChildTo(group);
label.x = obj.gridX.center();
label.y = y;
label.fill = '#fedc60'; // 塗りつぶし色
var label = make_label(group, text, 20, obj.gridX.center(-1), y,'#fedc60');
return label;
}
//正答率ラベル作成
function make_pass_rate_label(obj, x, y){
if(IS_LOCAL) return null;
var label = Label("正答率-%").addChildTo(obj);
label.x = x;
label.y = y;
label.fill = '#fedc60'; // 塗りつぶし色
label.fontSize = 20;
var label = make_label(obj, "正答率-%", 20, x, y,'#fedc60', 20);
return label;
}

@@ -148,11 +108,7 @@ function make_black(obj, w, h, a, grid_x, grid_y){
onclick_event(obj, group, is_correct, origin_question, Number(e.pointer.x), Number(e.pointer.y));
}
};
var label = Label(new_line(text, 16)).addChildTo(group);
label.x = obj.gridX.center(-7);
label.y = y
label.fill = '#5a4e46'; // 塗りつぶし色
label.align = 'left';
var label = make_label(group, text, 16, obj.gridX.center(-7), y,'#5a4e46');
return group;
}

@@ -27,10 +27,11 @@ function show_share_screen(obj){
var check = make_check_button(obj, obj.gridX.center(-4), 1250);

if(!IS_LOCAL){
var name_label = make_name_label(obj, 120, 175, "Twitterシェア");
result = (correct_num >= CLEAR_QUESTION_NUMBER) ? "合格" : "不合格";
text = "ソフトウェアテスト知識試験テスターちゃんレベルで" + correct_num + "/" + FINISH_QUESTION_NUMBER + "の成績で" + result + "でした。かかった時間は" + time_label + "でした。";
var label = make_story_label(obj, 50, 270, new_line(text, 20));

var name_label = make_label(obj, "Twitterシェア", 20, 120, 175, '#fedc60');
var label = make_label(obj, text, 20, 50, 270, '#5a4e46');
var twitter_icon = make_twitter_icon(obj, obj.gridX.center(), obj.gridY.center(-1), text);
if(is_clear){
var present = make_present_button(obj, obj.gridX.center(), 1000);
@@ -1,7 +1,4 @@
var LABEL_X = 50;
var LABEL_Y = 900;
var label = "";
var scenario_line = 0;


phina.define('Story', {
superClass: 'DisplayScene',
@@ -35,7 +32,7 @@ function show_story_window(obj){
char = make_charactor(obj, 'rin_normal', obj.gridX.center(1), obj.gridY.center(1), 0.1);
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, "凛太朗");
var name_label = make_name_label(obj, 20, 774, "凛太朗");
label = make_story_label(obj, LABEL_X, LABEL_Y, "");
scenario_line = next_messege(obj, scenario_line);
}
@@ -66,11 +63,7 @@ function next_messege(obj, 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';
var label = make_label(obj, text, 20, x, y,'#5a4e46');
label.lineHeight = 1.5;
return label;
}
@@ -104,11 +97,8 @@ function make_skip_button(obj, x, y){
return button;
}

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

0 comments on commit 6e73d1f

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