Posts

java - LibGDX + Box2D : Object Positioning -

Image
i'm trying code breakout games libgdx , box2d. there 1 point don't understand. there must 2 bricks touch edge. on emulator saw 2 bricks nested. here's createbox method's code: private void createbox(float posx, float posy, float boxw, float boxh) { bodydef bodydef = new bodydef(); bodydef.type = bodydef.bodytype.staticbody; bodydef.position.set(posx, posy); body body = world.createbody(bodydef); polygonshape shape = new polygonshape(); shape.setasbox(boxw, boxh); fixturedef fixturedef = new fixturedef(); fixturedef.shape = shape; fixturedef.density = 1f; fixture fixture = body.createfixture(fixturedef); shape.dispose(); } edit: multiplied code. createbox(cons_holder.bricks_left_margin + (i * cons_holder.brick_width * 2 ), cons_holder.brick_top_screen_margin + (j * cons_holder.brick_height * 2 ) + cons_holder.bricks_top_margin, cons_holder.brick_width / 2, ...

android - Matter of Handlers execution in a sequence -

i took snipet site explaining handler in android (a threading thing). @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); thread mythread = new thread(new runnable() { @override public void run() { (int = 0; < 4; i++) { try { timeunit.seconds.sleep(2); } catch (interruptedexception e) { e.printstacktrace(); } if (i == 2) { muihandler.post(new runnable() { @override public void run() { toast.maketext(myactivity.this, "i @ middle of background task", toast.length_long) .show(); } ...

Dynamically Change CSS with Javascript or jQuery -

i have snippet of code in change css dynamically based on values being greater 0. value of '0' class = 'cart-summary__count'. value greater '0' class = 'cart-summary__count_full'. <span class="cart-summary__count" data-v-observable="cart-count">0</span> <span class="cart-summary__count" data-v-observable="cart-count">1</span> *edit: <div id="cart-summary"> <span class="cart-summary__count" data-v-observable="cart-count">0</span> <a href class="cart">example.com</a> </div> change to: <a href class="cart-full">example.com</a> i still learning js , appreciated. cart value can change on page when adding item. please use code $(document).ready(function() { $("span").each(function(){ if (parseint($(this).text()) > 0){ $(this).removeclass(...

c# - Error in declaring default parameters for method -

this question has answer here: optional parameters “must compile-time constant” 8 answers i using default parameters i'm getting error default parameter value 'regularexpression' must compile time constant here method signature: public static pipe.datatypes.buyflow.entities.question getemailaddressquestion(string regularexpression = regularexpressions.emailaddressregex, int rank = 1, bool isrequired = true) { } and here property: public static string emailaddressregex { { string emailaddressregex = @"^[a-za-z0-9\._%\+\-]+@([a-za-z0-9\-]{1,40}\.)+([a-za-z0-9]{2,4}|museum)$"; return emailaddressregex; } } it error message says. default parameters have constants (at compile time). the getter of emailaddressregex return different values during runtime. same value not known compiler. ...

android - How to connect paired device via Bluetooth for TV(REMOTE)? -

my code mbluetoothadapter = bluetoothadapter.getdefaultadapter(); if (mbluetoothadapter != null) { // device not support bluetooth if (!mbluetoothadapter.isenabled()) { intent enablebtintent = new intent(bluetoothadapter.action_request_enable); startactivityforresult(enablebtintent, 10); }else{ set<bluetoothdevice> paireddevices = mbluetoothadapter.getbondeddevices(); // if there paired devices if (paireddevices.size() > 0) { // loop through paired devices (final bluetoothdevice device : paireddevices) { // add name , address array adapter show in listview //marrayadapter.add(device.getname() + "\n" + device.getaddress()); devname = device.getname(); devadd = device.getaddress(); if(!devname.isempty()) { ...

excel - Fill a column with UserForm -

i want fill column userform. user has 4 options how column can filled. problem right know is, first option works (2). input-mask wont disappear after click ok-button. chosen option should copied column h , filled automatically. mistakes? private sub commandbutton1_click() ' ok button dim emptyrow range dim lastrow long lastrow = cells.specialcells(xlcelltypelastcell).row worksheets("sheet1").activate set emptyrow = worksheets("sheet1").range("h2:h" & lastrow) if optionbutton2.value = true emptyrow.value = "2" if optionbutton3.value = true emptyrow.value = "3" if optionbutton4.value = true emptyrow.value = "4" if optionbutton5.value = true emptyrow.value = "5" end if end if end if end if end sub give shot.. biggest difference here how if statement written. original code had if statements nested in ea...

How to connect to a database without the config file in Yii2? -

i using, same problem, code given in question yii2 create database connection . i realise $config variable no longer 1 in web.php file, "config" folder, , changing $config in configuration::setconfig() function. my question more experienced me in yii should write in web.php file in db field (or in db.php file) "create database connection programmatically without using config file" ? in function configuration::setconfig() configure application? i'm sorry if question not clear enough. please ask details in comments if needed. thank you! you can define new connection way $db = new yii\db\connection([ 'dsn' => 'mysql:host=localhost;dbname=example', 'username' => 'root', 'password' => '', 'charset' => 'utf8', ]); , $db->open(); after db connection established, 1 can execute sql statements following eg: : $command = $db->createcomm...