Daily Archives

Articles indexed Sunday October 27 2013

Page 9/13 | < Previous Page | 5 6 7 8 9 10 11 12 13  | Next Page >

  • Keyboard is not detecting as3

    - by Kaoru
    i got this problem, when i press 1 in keyboard, the function does not run, even i already declared it. How do i solve this? Here is the code: public function Character() { Constant.loaderMario.load(new URLRequest("mario.swf")); addEventListener(KeyboardEvent.KEY_DOWN, selectingPlayer); } private function selectingPlayer(event:KeyboardEvent):void { isoTextMario = new Word(); isoTextChocobo = new Word(); if (event.keyCode == Keyboard.NUMBER_1|| event.keyCode == 49) { Constant.marioSelected = true; if (Constant.marioSelected == true) { isoTextMario.marioCharacter(); addChild(isoTextMario); } } else if (event.keyCode == Keyboard.NUMBER_2 || event.keyCode == 50) { Constant.chocoboSelected = true; if (Constant.chocoboSelected == true) { isoTextChocobo.chocoboCharacter(); addChild(isoTextChocobo); } } }

    Read the article

  • Implementing algorithms via compute shaders vs. pipeline shaders

    - by TravisG
    With the availability of compute shaders for both DirectX and OpenGL it's now possible to implement many algorithms without going through the rasterization pipeline and instead use general purpose computing on the GPU to solve the problem. For some algorithms this seems to become the intuitive canonical solution because they're inherently not rasterization based, and rasterization-based shaders seemed to be a workaround to harness GPU power (simple example: creating a noise texture. No quad needs to be rasterized here). Given an algorithm that can be implemented both ways, are there general (potential) performance benefits over using compute shaders vs. going the normal route? Are there drawbacks that we should watch out for (for example, is there some kind of unusual overhead to switching from/to compute shaders at runtime)? Are there perhaps other benefits or drawbacks to consider when choosing between the two?

    Read the article

  • Changing State in PlayerControler from PlayerInput

    - by Jeremy Talus
    In my player input I wanna change the the "State" of my player controller but I have some trouble to do it my player input is declared like that : class ResistancePlayerInput extends PlayerInput within ResistancePlayerController config(ResistancePlayerInput); and in my playerControler I have that : class ResistancePlayerController extends GamePlayerController; var name PreviousState; DefaultProperties { CameraClass = class 'ResistanceCamera' //Telling the player controller to use your custom camera script InputClass = class'ResistanceGame.ResistancePlayerInput' DefaultFOV = 90.f //Telling the player controller what the default field of view (FOV) should be } simulated event PostBeginPlay() { Super.PostBeginPlay(); } auto state Walking { event BeginState(name PreviousStateName) { Pawn.GroundSpeed = 200; `log("Player Walking"); } } state Running extends Walking { event BeginState(name PreviousStateName) { Pawn.GroundSpeed = 350; `log("Player Running"); } } state Sprinting extends Walking { event BeginState(name PreviousStateName) { Pawn.GroundSpeed = 800; `log("Player Sprinting"); } } I have tried to use PCOwner.GotoState(); and ResistancePlayerController(PCOwner).GotoState(); but won't work. I have also tried a simple GotoState, and nothing happen how can I call GotoState for the PC Class from my player input ?

    Read the article

  • Software design of a browser-based strategic MMO game

    - by Mehran
    I wonder if there are any known tested software designs for Travian-like browser-based strategic MMO games? I mean how would they implement the server of such games or what is stored in database and what is stored in RAM? Is the state of the world stored in one piece or is it distributed among a number of storage? Does anyone know a resource to study the problems and solutions of creating such games? [UPDATE] Suggested in comments, I'm going to give an example how would I design such a project. Even though I'm not sure if I'm proposing the right one. Having stored the world state in a MongoDB, I would implement an event collection in which all the changes to the world will register. Changes that are meant to happen in the future will come with an action date set to the future and those that are to be carried out immediately will be set to now. Having this datastore as the central point of the system, players will issue their actions as events inserted in datastore. At the other end of the system, I'll have a constant-running software taking out events out of the datastore which are due to be carried out and not done yet. Executing an event means apply some update on the world's state and thus the datastore. As scalable as this design sounds, I'm not sure if it will be worth implementing. For one, it is pointless to cache the datastore as most of updates happen once without any follow ups. For instance if you have the growth of resources in your game, you'll be updating the whole world state periodically in which case, having incorporated a cache, you are keeping the whole world in RAM (which most likely is impossible). So can someone come up with a better design?

    Read the article

  • Calling a method with an instance of derived class of derived generic type

    - by madsbirk
    Okay, so I have classes class B<T> : A<T> class L : K and a method void Method(A<K> a) {...} What I would like to do is this b = new B<L>(); Method(b); //error But it is not possible to b to the correct type. Indeed it is not possible to make this cast A<K> t = new A<L>(); //error I would really like to not have to change the internals of Method. I have no problems making changes to B and/or L. Do I have any options for making some sort of workaround? I guess it should be possible for Method to execute all of its method calls etc. on b, since B derives from A and L derives from K?

    Read the article

  • Raw Video file from website

    - by Charlie
    I would like to make an app that will download videos files that can be played later. At first i thought I could have a UIWeb view and then try to access the cache of it and get the file that way but unfortunately i don't have access to that. After trying that my next thought would be get the direct link to the video file. Essentially what download helper does on fire fox. Any idea of where i could look at for help or any body have any better idea? Is there any stringByEvaluatingjavascript that might be of use or is there away to access the cache on a webview in your own app? Thanks for any help!

    Read the article

  • How to set variable before callback is called?

    - by user1995327
    I'm trying to design a webpage... I have a function that I call get all info needed for an idividuals home page. A snippet of the codes is: exports.getHomePageData = function(userId, cb) { var pageData = {}; pageData.userFullName = dbUtil.findNameByUserId(userId, function(err){ if (err) cb(err); }); pageData.classes = dbUtil.findUserClassesByUserId(userId, function(err){ if (err) cb(err); }); cb(pageData); } The problem I'm having is the cb(pageData) is being called before I even finish setting the elements. I've seen that people use the async library to solve this but I was wondering if there was any other way for me to do it without needing more modules... Thanks!

    Read the article

  • apache tomcat 8 websocket origin and client address

    - by user2926082
    i hope someone can help me ... i am using apache tomcat 8.0.0-RC5 and JSR-356 web socket API ... I have 2 questions: 1) Is it possible to get the client ip on @OnOpen method ?? 2) Is it possible to get the origin of the connection ??? I followed the websocket example which comes with the distribution of tomcat and i was not able to find the answers .... My java class is basically as follow @ServerEndpoint(value = "/data.socket") public class MyWebSocket { @OnOpen public void onOpen(Session session) { // Here is where i need the origin and remote client address } @OnClose public void onClose() { // disconnection handling } @OnMessage public void onMessage(String message) { // message handling } @OnError public void onError(Session session, Throwable throwable) { // Error handling } }

    Read the article

  • Gluster strange issue with shared mount point like seprate mount.

    - by Satish
    I have two nodes and for experiment i have install glusterfs and create volume and successfully mounted on own node, but if i create file in node1 it is not showing in node2, look like both behaving like they are separate. node1 10.101.140.10:/nova-gluster-vol 2.0G 820M 1.2G 41% /mnt node2 10.101.140.10:/nova-gluster-vol 2.0G 33M 2.0G 2% /mnt volume info split brian $ sudo gluster volume heal nova-gluster-vol info split-brain Gathering Heal info on volume nova-gluster-vol has been successful Brick 10.101.140.10:/brick1/sdb Number of entries: 0 Brick 10.101.140.20:/brick1/sdb Number of entries: 0 test node1 $ echo "TEST" > /mnt/node1 $ ls -l /mnt/node1 -rw-r--r-- 1 root root 5 Oct 27 17:47 /mnt/node1 node2 (file isn't there, while they are shared mount) $ ls -l /mnt/node1 ls: cannot access /mnt/node1: No such file or directory What i am missing??

    Read the article

  • Live output from .jar executed by PHP

    - by user2926097
    I have a php-script which executes a .jar-file: <?php passthru("java -jar nlp-server.jar 9000"); ?> I want to display the output generated by this .jar-file on a website. The problematic part is the fact that the .jar-file doesnt finish executing because its a server-application. Thus navigating to the php-file wont help and I didnt manage to make AJAX work either. Is there a way to display the "live" output of the .jar-file on a website?

    Read the article

  • How to count how many items for distinct items in mysql?

    - by Vincent Duprez
    Imagine a have a table with a column named status: status ------ A A A B C C D D D How can I count how many rows have A, how many rows have B etc? this kind of output: A |B |C |D |E ------------------ 3 |1 |2 |3 |0 As for E = O , this will always be A,B,C,D and E Output should be one row (thus 1 query). When doing a distinct count (most returning answer on my searches, it does return how many different elements there are, 4 in this case...)

    Read the article

  • How do I randomly select from a list in Python?

    - by Liam Block
    Basically, I've got a homework task of programming a text based battle simulator in Python. Obviously I've gone with pokémon... I would like the enemy to be randomly selected, however I don't know how to randomly select from a list... foo = ['a', 'b', 'c', 'd', 'e'] from random import choice print choice(foo) This is what I've been told to try but I've got no modules or anything imported... How can I make this work, appreciated.

    Read the article

  • Error with characters in a html iframe

    - by dinero beta
    excuse my English I speak Spanish I'm trying to display multiple php and mysql registration, after that the show in an iframe the problem is that apparently in the iframe shows me errors accents and other characters for example: for example (?D?nde cuesta menos y se consume m?s?") this is what shows (?) In the original query or first does not show me that, but in the iframe shows me that error and probe with http-equiv = "content-type" and I worked What else I can do? What should I do? regards

    Read the article

  • jQuery Sparklines: $.getJSON data can't be read

    - by Bob Jansen
    I'm trying to generate a pie graph with Sparklines but I'm running into some trouble. I can't seem to figure out what I'm doing wrong, but I feel it is a silly mistake. I'm using the following code to generate a sparkline chart in the div #traffic_bos_ss: //Display Visitor Screen Size Stats $.getJSON('models/ucp/traffic/traffic_display_bos.php', { type: 'ss', server: server, api: api, ip: ip, }, function(data) { var values = data.views; //alert(values); $('#traffic_bos_ss').sparkline(values, { type: "pie", height: "100%", tooltipFormat: 'data.screen - {{value}}', }); }); The JSON string fetched: {"screen":"1220x1080, 1620x1080, 1920x1080","views":"[2, 2, 61]"} For some reason Sparklines does not process the variable values. When I alert the variable it outputs "[2, 2, 61]". Now the jQuery code does work when I replace the snippet: var values = data.views; with var values = [2, 2, 61]; What am I doing wrong?

    Read the article

  • What's the right Java generic for a collection of elements with unique addressable indices?

    - by Rocreex
    I'm on my way to programming a database application and in our course we are told to implement a library of elements using one of the Java Collections. Each of the elements has a unique ID with which it's supposed to be addressed. Now I am wondering how this can be done. I though about using a ListArray but this won't work because the only way of addressing List elements is through the index which you can't control. Do you have some advice for me?

    Read the article

  • Better way to get int from FragmentActivity in a Fragment?

    - by Gimberg
    Hi im trying to get an int from my FragmentActivity and i have a way to do this but the code get very cluttered and long and i did this to shorten the problem and i don't get any errors while in the editor but when i run the app it eminently crashes. Any suggestions? An example of the code that doesn't work MainActivity mainActivity = ((MainActivity)getActivity()); public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.upgrades_fragment, container, false); TextView AirFreshenersCost = (TextView) view.findViewById(R.id.AirFreshenersCost ); if(mainActivity.amountAirFresheners == 5){ AirFreshenersCost.setText("5"); } return view; } LogCat 10-27 22:16:37.333: E/AndroidRuntime(5593): FATAL EXCEPTION: main 10-27 22:16:37.333: E/AndroidRuntime(5593): java.lang.NullPointerException 10-27 22:16:37.333: E/AndroidRuntime(5593): at com.free.dennisg.clickingbad.fragments.UpgradesFragment.onCreateView(UpgradesFragment.java:40) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.support.v4.view.ViewPager.populate(ViewPager.java:1068) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.support.v4.view.ViewPager.populate(ViewPager.java:914) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.support.v4.view.ViewPager$3.run(ViewPager.java:244) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.view.Choreographer.doCallbacks(Choreographer.java:562) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.view.Choreographer.doFrame(Choreographer.java:531) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.os.Handler.handleCallback(Handler.java:730) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.os.Handler.dispatchMessage(Handler.java:92) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.os.Looper.loop(Looper.java:137) 10-27 22:16:37.333: E/AndroidRuntime(5593): at android.app.ActivityThread.main(ActivityThread.java:5289) 10-27 22:16:37.333: E/AndroidRuntime(5593): at java.lang.reflect.Method.invokeNative(Native Method) 10-27 22:16:37.333: E/AndroidRuntime(5593): at java.lang.reflect.Method.invoke(Method.java:525) 10-27 22:16:37.333: E/AndroidRuntime(5593): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 10-27 22:16:37.333: E/AndroidRuntime(5593): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555) 10-27 22:16:37.333: E/AndroidRuntime(5593): at dalvik.system.NativeStart.main(Native Method) An example of the code that work public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.upgrades_fragment, container, false); TextView AirFreshenersCost = (TextView) view.findViewById(R.id.AirFreshenersCost ); if(((MainActivity)getActivity()).amountAirFresheners == 5){ AirFreshenersCost.setText("5"); } return view; }

    Read the article

  • Saving data that is in a table efficiently and also is easy to retrieve and echo back out

    - by Harry
    Information I currently have a table which image is below, Problem I have made this table using ul & li Here is the code http://jsfiddle.net/8j2qe/1/ Question What would be the best way of storing the data in the image and easily displaying it? Keeping in mind that each column can only have 1 entry. Thank you! And any questions will be answered ASAP! EDIT Sorry, I dont think I was clear enough in my initial question. What I am asking is, what is the best way to store and then display this type of data. I want to DISPLAY data from my database to show like it would in the image. Should I have a column in my database for each column on the table, then say either A,B,C or D depending on what column it is in but then how would I display it using PHP in my code provided? Im struggling to find a good way of explaining this, I am sorry.

    Read the article

  • Exponential regression : p-value and F significance

    - by Saravanan K
    I am new to statistics. I have a set of independent data and dependent data (X,Y), where I would like to do an exponential regression to obtain its p-value and significant F (already obtained R2 and also the coefficients through mathematical calculation). What is the natural evolution from the (X,Y) data to mathematically calculate those variables. Spent a week on the internet to study this but unable to find the right answer. Often an exponential data, y=be^(mx) will be converted first to a linear data, ln y = mx + ln b . Then a linear regression will done on the converted data, obtaining its p-value etc. Assume we use a statistical tool such as Excel's Analysis ToolPak: Data Analysis : Regression, it will produce a result such as below, I believe the p-value and Significant F value is representing the converted linear data and not the original exponential data. Questions: What is the approach/steps used by Excel to get the p-value and Significant F value for the converted linear data as shown in the statistic output in the image above? It is not clear in their help page or website. Can the p-value and Significant F could be mathematically calculated for exponential regression without using a statistical tool? Can you assist to point me to the right link if this has been answered before.

    Read the article

  • adding results of XML request to a page

    - by user2925833
    I am trying to get a feel for adding content to a page with XMLHTTPRequest. I would like to add the results to existing page content say in a second column, but I am not having any luck. I would appreciate a shove in the right direction. Thanks for any help. <!DOCTYPE html> <html> <head> <style> #button{ float: left; } #team{ float: left; } </style> <title>XMLHTTPRequest</title> <script src="jquery-1.10.2.js"></script> <script> $(document).ready(function(){ xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(){ if (xhr.readyState == 4 && xhr.status == 200) { xmlDoc = xhr.responseXML; var team = xmlDoc.getElementsByTagName("teammember"); var html = ""; for (i = 0; i < team.length; i++){ html += xmlDoc.getElementsByTagName("name")[i].childNodes[0].nodeValue + "<br>" + xmlDoc.getElementsByTagName("title")[i].childNodes[0].nodeValue + "<br>" + xmlDoc.getElementsByTagName("bio")[i].childNodes[0].nodeValue + "<br><br>"; } //this is the code I would like help with var team = document.getElementById("team"); team.appendChild(document.createTextNode("html")); } } xhr.open("GET", "team.xml", true); }); </script> </head> <body> <div id="button"> <button onclick="xhr.send()">Click Me!</button> </div> <div id="team"> </div> </body> </html>

    Read the article

  • How to convert ISampleGrabber::BufferCB's buffer to a bitmap

    - by user2509919
    I am trying to use the ISampleGrabberCB::BufferCB to convert the current frame to bitmap using the following code: int ISampleGrabberCB.BufferCB(double sampleTime, IntPtr buffer, int bufferLength) { try { Form1 form1 = new Form1("", "", ""); if (pictureReady == null) { Debug.Assert(bufferLength == Math.Abs(pitch) * videoHeight, "Wrong Buffer Length"); } Debug.Assert(imageBuffer != IntPtr.Zero, "Remove Buffer"); Bitmap bitmapOfCurrentFrame = new Bitmap(width, height, capturePitch, PixelFormat.Format24bppRgb, buffer); MessageBox.Show("Works"); form1.changepicturebox3(bitmapOfCurrentFrame); pictureReady.Set(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } return 0; } However this does not seem to be working. Additionally it seems to call this function when i press a button which runs the following code: public IntPtr getFrame() { int hr; try { pictureReady.Reset(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } imageBuffer = Marshal.AllocCoTaskMem(Math.Abs(pitch) * videoHeight); try { gotFrame = true; if (videoControl != null) { hr = videoControl.SetMode(stillPin, VideoControlFlags.Trigger); DsError.ThrowExceptionForHR(hr); } if (!pictureReady.WaitOne(9000, false)) { throw new Exception("Timeout waiting to get picture"); } } catch { Marshal.FreeCoTaskMem(imageBuffer); imageBuffer = IntPtr.Zero; } return imageBuffer; } Once this code is ran I get a message box which shows 'Works' thus meaning my BufferCB must of been called however does not update my picture box with the current image. Is the BufferCB not called after every new frame? If so why do I not recieve the 'Works' message box? Finally is it possible to convert every new frame into a bitmap (this is used for later processing) using BufferCB and if so how? Edited code: int ISampleGrabberCB.BufferCB(double sampleTime, IntPtr buffer, int bufferLength) { Debug.Assert(bufferLength == Math.Abs(pitch) * videoHeight, "Wrong Buffer Length"); Debug.Assert(imageBuffer != IntPtr.Zero, "Remove Buffer"); CopyMemory(imageBuffer, buffer, bufferLength); Decode(buffer); return 0; } public Image Decode(IntPtr imageData) { var bitmap = new Bitmap(width, height, pitch, PixelFormat.Format24bppRgb, imageBuffer); bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); Form1 form1 = new Form1("", "", ""); form1.changepicturebox3(bitmap); bitmap.Save("C:\\Users\\...\\Desktop\\A2 Project\\barcode.jpg"); return bitmap; } Button code: public void getFrameFromWebcam() { if (iPtr != IntPtr.Zero) { Marshal.FreeCoTaskMem(iPtr); iPtr = IntPtr.Zero; } //Get Image iPtr = sampleGrabberCallBack.getFrame(); Bitmap bitmapOfFrame = new Bitmap(sampleGrabberCallBack.width, sampleGrabberCallBack.height, sampleGrabberCallBack.capturePitch, PixelFormat.Format24bppRgb, iPtr); bitmapOfFrame.RotateFlip(RotateFlipType.RotateNoneFlipY); barcodeReader(bitmapOfFrame); } public IntPtr getFrame() { int hr; try { pictureReady.Reset(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } imageBuffer = Marshal.AllocCoTaskMem(Math.Abs(pitch) * videoHeight); try { gotFrame = true; if (videoControl != null) { hr = videoControl.SetMode(stillPin, VideoControlFlags.Trigger); DsError.ThrowExceptionForHR(hr); } if (!pictureReady.WaitOne(9000, false)) { throw new Exception("Timeout waiting to get picture"); } } catch { Marshal.FreeCoTaskMem(imageBuffer); imageBuffer = IntPtr.Zero; } return imageBuffer; } I also still need to press the button to run the BufferCB Thanks for reading.

    Read the article

  • Phonegap: Slow response with vibrate notification

    - by jjei
    I created a simple android application with jquery and phonegap. When testing the app with phone, I noticed that vibration effect, that I have used to indicate that user touches a button, comes after a delay of maybe 0,5 seconds. This is way too long delay and just confuses the user. Is this just the downside of using phonegap? Or is there any configuration or additional frameworks which could be used to make the app response and produce the vibration more quickly? I installed the vibration plugin like this: phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration.git I use the code below to create the vibration effect. navigator.notification.vibrate(200); My phone gap version is 3.0.0-0.14.3

    Read the article

  • Navigating MainMenu with arrow keys or controller

    - by Phil Royer
    I'm attempting to make my menu navigable with the arrow keys or via the d-pad on a controller. So Far I've had no luck. The question is: Can someone walk me through how to make my current menu or any libgdx menu keyboard accessible? I'm a bit noobish with some stuff and I come from a Javascript background. Here's an example of what I'm trying to do: http://dl.dropboxusercontent.com/u/39448/webgl/qb/qb.html For a simple menu that you can just add a few buttons to and it run out of the box use this: http://www.sadafnoor.com/blog/how-to-create-simple-menu-in-libgdx/ Or you can use my code but I use a lot of custom styles. And here's an example of my code: import aurelienribon.tweenengine.Timeline; import aurelienribon.tweenengine.Tween; import aurelienribon.tweenengine.TweenManager; import com.badlogic.gdx.Game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Screen; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.Align; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.project.game.tween.ActorAccessor; public class MainMenu implements Screen { private SpriteBatch batch; private Sprite menuBG; private Stage stage; private TextureAtlas atlas; private Skin skin; private Table table; private TweenManager tweenManager; @Override public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); menuBG.draw(batch); batch.end(); //table.debug(); stage.act(delta); stage.draw(); //Table.drawDebug(stage); tweenManager.update(delta); } @Override public void resize(int width, int height) { menuBG.setSize(width, height); stage.setViewport(width, height, false); table.invalidateHierarchy(); } @Override public void resume() { } @Override public void show() { stage = new Stage(); Gdx.input.setInputProcessor(stage); batch = new SpriteBatch(); atlas = new TextureAtlas("ui/atlas.pack"); skin = new Skin(Gdx.files.internal("ui/menuSkin.json"), atlas); table = new Table(skin); table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // Set Background Texture menuBackgroundTexture = new Texture("images/mainMenuBackground.png"); menuBG = new Sprite(menuBackgroundTexture); menuBG.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // Create Main Menu Buttons // Button Play TextButton buttonPlay = new TextButton("START", skin, "inactive"); buttonPlay.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { ((Game) Gdx.app.getApplicationListener()).setScreen(new LevelMenu()); } }); buttonPlay.addListener(new InputListener() { public boolean keyDown (InputEvent event, int keycode) { System.out.println("down"); return true; } }); buttonPlay.padBottom(12); buttonPlay.padLeft(20); buttonPlay.getLabel().setAlignment(Align.left); // Button EXTRAS TextButton buttonExtras = new TextButton("EXTRAS", skin, "inactive"); buttonExtras.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { ((Game) Gdx.app.getApplicationListener()).setScreen(new ExtrasMenu()); } }); buttonExtras.padBottom(12); buttonExtras.padLeft(20); buttonExtras.getLabel().setAlignment(Align.left); // Button Credits TextButton buttonCredits = new TextButton("CREDITS", skin, "inactive"); buttonCredits.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { ((Game) Gdx.app.getApplicationListener()).setScreen(new Credits()); } }); buttonCredits.padBottom(12); buttonCredits.padLeft(20); buttonCredits.getLabel().setAlignment(Align.left); // Button Settings TextButton buttonSettings = new TextButton("SETTINGS", skin, "inactive"); buttonSettings.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { ((Game) Gdx.app.getApplicationListener()).setScreen(new Settings()); } }); buttonSettings.padBottom(12); buttonSettings.padLeft(20); buttonSettings.getLabel().setAlignment(Align.left); // Button Exit TextButton buttonExit = new TextButton("EXIT", skin, "inactive"); buttonExit.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.exit(); } }); buttonExit.padBottom(12); buttonExit.padLeft(20); buttonExit.getLabel().setAlignment(Align.left); // Adding Heading-Buttons to the cue table.add().width(190); table.add().width((table.getWidth() / 10) * 3); table.add().width((table.getWidth() / 10) * 5).height(140).spaceBottom(50); table.add().width(190).row(); table.add().width(190); table.add(buttonPlay).spaceBottom(20).width(460).height(110); table.add().row(); table.add().width(190); table.add(buttonExtras).spaceBottom(20).width(460).height(110); table.add().row(); table.add().width(190); table.add(buttonCredits).spaceBottom(20).width(460).height(110); table.add().row(); table.add().width(190); table.add(buttonSettings).spaceBottom(20).width(460).height(110); table.add().row(); table.add().width(190); table.add(buttonExit).width(460).height(110); table.add().row(); stage.addActor(table); // Animation Settings tweenManager = new TweenManager(); Tween.registerAccessor(Actor.class, new ActorAccessor()); // Heading and Buttons Fade In Timeline.createSequence().beginSequence() .push(Tween.set(buttonPlay, ActorAccessor.ALPHA).target(0)) .push(Tween.set(buttonExtras, ActorAccessor.ALPHA).target(0)) .push(Tween.set(buttonCredits, ActorAccessor.ALPHA).target(0)) .push(Tween.set(buttonSettings, ActorAccessor.ALPHA).target(0)) .push(Tween.set(buttonExit, ActorAccessor.ALPHA).target(0)) .push(Tween.to(buttonPlay, ActorAccessor.ALPHA, .5f).target(1)) .push(Tween.to(buttonExtras, ActorAccessor.ALPHA, .5f).target(1)) .push(Tween.to(buttonCredits, ActorAccessor.ALPHA, .5f).target(1)) .push(Tween.to(buttonSettings, ActorAccessor.ALPHA, .5f).target(1)) .push(Tween.to(buttonExit, ActorAccessor.ALPHA, .5f).target(1)) .end().start(tweenManager); tweenManager.update(Gdx.graphics.getDeltaTime()); } public static Vector2 getStageLocation(Actor actor) { return actor.localToStageCoordinates(new Vector2(0, 0)); } @Override public void dispose() { stage.dispose(); atlas.dispose(); skin.dispose(); menuBG.getTexture().dispose(); } @Override public void hide() { dispose(); } @Override public void pause() { } }

    Read the article

  • MySQL Database is Indexed at Apache Solr, How to access it via URL

    - by Wasim
    data-config.xml <dataConfig> <dataSource encoding="UTF-8" type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/somevisits" user="root" password=""/> <document name="somevisits"> <entity name="login" query="select * from login"> <field column="sv_id" name="sv_id" /> <field column="sv_username" name="sv_username" /> </entity> </document> </dataConfig> schema.xml <?xml version="1.0" encoding="UTF-8" ?> <schema name="example" version="1.5"> <fields> <field name="sv_id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> <field name="username" type="string" indexed="true" stored="true" required="true"/> <field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/> <field name="text" type="string" indexed="true" stored="false" multiValued="true"/> </fields> <uniqueKey>sv_id</uniqueKey> <types> <fieldType name="string" class="solr.StrField" sortMissingLast="true" /> <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/> </types> </schema> Solr successfully imported mysql database using full http://[localSolr]:8983/solr/#/collection1/dataimport?command=full-import My question is, how to access that mysql imported database now?

    Read the article

  • Looping through NSArray while subtracting values from each object? [on hold]

    - by Julian
    I have NSNumber objects stored in an NSMutableArray. I am attempting to perform a calculation on each object in the array. What I want to do is: 1) Take a random higher number variable and keep subtracting a smaller number variable in increments until the value of the variable is equal to the value in the array. For example: NSMutableArray object is equal to 2.50. I have an outside variable of 25 that is not in the array. I want to subtract 0.25 multiple times from the variable until I reach less than or equal to 2.50. I also need a parameter so if the number does not divide evenly and goes below the array value, it resorts to the original array value of 2.50. Lastly, for each iteration, I want to print the values as they are counting down as a string. I was going to provide code, but I don't want to make this more confusing than it has to be. So my output would be: VALUE IS: 24.75 VALUE IS: 24.50 VALUE IS: 24.25 … VALUE IS: 2.50 END

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13  | Next Page >