扩展Phaser.js类(extending Phaser.js classes)
我正在使用Phaser框架,我想创建一个新的类来保存phaser中sprite类的所有属性,所以我尝试这样做
var mario = function(){ Phaser.Sprite.call(this); // inherit from sprite };
但出现错误“Uncaught TypeError:undefined不是函数”
然后我尝试了
var mario = function(){ this.anything = ""; }; mario.prototype = new Phaser.Sprite();
确定它有效,但它调用了相位器构造函数,我不想创建精灵,直到我做
var heroObj = new mario();
我该怎么办 ?
im working with Phaser framework , i want to create new class that hold all properties from sprite class in phaser so i tried doing this
var mario = function(){ Phaser.Sprite.call(this); // inherit from sprite };
but there was an error "Uncaught TypeError: undefined is not a function"
then i tried
var mario = function(){ this.anything = ""; }; mario.prototype = new Phaser.Sprite();
OK it works but it called phaser constructor and i don't want to create sprite until i do
var heroObj = new mario();
what should i do ?
原文:https://stackoverflow.com/questions/29231281
最满意答案
您想使用可选参数 :
Route::get('/{id?}', 'HomeController@index');
有时您可能需要指定路由参数,但可以选择存在该路由参数。 您可以通过放置一个
?
参数名称后面的标记。You want to use optional parameters:
Route::get('/{id?}', 'HomeController@index');
Occasionally you may need to specify a route parameter, but make the presence of that route parameter optional. You may do so by placing a
?
mark after the parameter name.
相关问答
更多-
更改: public function getGlobalData(Request $request, $part){ 至: public function getGlobalData(Request $request, $part = null){ Change: public function getGlobalData(Request $request, $part){ to: public function getGlobalData(Request $request, $part = nul ...
-
我想这可能会帮助你找到一个在Laravel中使用AJAX的基本方法。 这是一段非常古老的代码,但它适用于jajajaja 控制器端: /** * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function getRamos(Request $request) { $check = Ramo::find($request->input('ramo')); $subramos = Su ...
-
自Laravel 5.2以来,身份验证系统更容易启动和运行。 你可以简单地运行这个命令: php artisan make:auth 这将负责设置必要的身份验证资源:路由定义,视图等。有关Laravel文档中主题的更多信息。 您还可以查看本文以查看Laravel 5.2的新增功能。 Since Laravel 5.2, the authentication system is much easier to get up and running. You can simply run this comman ...
-
你试过这段代码吗? 此方法应该在您的控制器中。 public function getView($id) { dd($id); } 如果有帮助,请告诉我。 谢谢 Have you tried this code? This method should be in your controller. public function getView($id) { dd($id); } Let me know if that helped. Thank ...
-
您正在使用FormRequests充当该控制器方法的验证。 在这种情况下,您的FormRequest是:MessageRequest - 其中包含category名称的验证参数。 当您的ajax提交发生时,它没有提供category字段,因此未通过验证。 要进行测试,请尝试向ajax数据提供类别数据: data: {formData:form_data,formTaxonomy: form_taxonomy, category: 'somevalue-unique-to-your-taxonomies'}, ...
-
您想使用可选参数 : Route::get('/{id?}', 'HomeController@index'); 有时您可能需要指定路由参数,但可以选择存在该路由参数。 您可以通过放置一个? 参数名称后面的标记。 You want to use optional parameters: Route::get('/{id?}', 'HomeController@index'); Occasionally you may need to specify a route parameter, but make ...
-
在laravel 5.2(Where in laravel 5.2)[2024-02-27]
我认为这是因为您正在使用GET请求将多个counties值传递给您的控制器,但未在您的请求中使用正确的counties[]参数。 目前,如果你要做一个dd($countiesList); 在你的函数中,你不会得到一个数组,因为你没有传递一个数组; 你传递一个单一的价值。 要在GET请求中将参数指定为数组,您需要执行以下操作: /leads/regions/counties/zipcodes?counties[]=one&counties[]=two... 对于您尝试过滤的每个counties价值。 您可能 ... -
Laravel 5.2路由错误(Laravel 5.2 Route Error)[2021-12-19]
错误 Route [tasks.index]未定义。 (查看:D:\ wamp \ www \ test1 \ resources \ views \ pages \ home.blade.php) 这是因为您已将其命名为index而不是tasks.index ,因此要么在路由声明中将名称从index更改为tasks.index ,要么在引用href属性中的路径时使用index 。 现在你有了这个: Route::get('/index', [ 'as' => 'index', // index i ... -
按照这些简单的步骤 如果您的routes.php有Route::auth() ,请删除该行。 现在routes.php添加到routes.php Route::get('super/admin', 'Auth\AuthController@getLogin')->name('auth.login.get'); Route::post('super/admin', 'Auth\AuthController@postLogin')->name('auth.login.post'); Route::get('su ...