Daily Archives

Articles indexed Monday November 5 2012

Page 12/17 | < Previous Page | 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Is it possible to use a spherical collision component in UDK?

    - by Almo
    I have an object in UDK, which has a SkeletalMesh. At certain times in the game, I want this object to continue rendering the SkeletalMesh, but I'd like it to use spherical collision temporarily. After reading a bunch about PrimitiveComponents, my understanding is that UDK supports cylindrical and box-like collision, but not spherical without using a static mesh. But it seems an attached static mesh will render, since it has no bHidden attribute. There must be a way to do this, but I don't know UDK well enough yet to understand all the pitfalls.

    Read the article

  • how to make a continuous machine gun sound-effect

    - by Jan
    I am trying to make an entity fire one or more machine-guns. For each gun I store the time between shots (1.0 / firing rate) and the time since the last shot. Also I've loaded ~10 different gun-shot sound-effects. Now, for each gun I do the following: function update(deltatime): timeSinceLastShot += deltatime if timeSinceLastShot >= timeBetweenShots + verySmallRandomValue(): timeSinceLastShot -= timeBetweenShots if gunIsFiring: displayMuzzleFlash() spawnBullet() selectRandomSound().play() But now I often get a crackling noise (which I assume is when two or more guns are firing at the same time and confuse the sound-device). My question is whether A) This a common problem and there is a well-known solution, maybe to do with the channels or something, or B) I am using a completely wrong approach to the task. I had a look at some sound-assets for other games and they used complete burst with multiple shots. I suppose I could try that, but I would like to have organic little hickups in the gun-fire (that's what the random value is for) to make the game more gritty and dirty. I am using Panda3D, but I had the exact same problem in PyGame and SDL. [edit] Thanks a lot for the answers so far! One more problem with faking it though: Now how do I stop the sound? Let's say I have an effect with 5 bangs... *bang* *bang* *bang* *bang* *bang* And I magically manage to loop it so that there's no gap or overlap if the player fires more than 5 shots. Now, what do I do if the player stops firing halfway through the third bang? How do I know how long to keep playing the sample so that the third bang is completed and I can start playing the rumbling echo of the last shot? Of course I can look up the shot/pause timing of that sound-sample and code accordingly, but it feels extremely hacky.

    Read the article

  • Guitar hero clone and music

    - by mm24
    I am an indie game developer and I am doing a game similar to guitar hero. I am using tracks composed by musicians and I contacted them to sing a licensing contract. As is my first indie project I have no idea on how I should deal with the royalties aspect of this because each track as an ISRC code and each time a track is played in public there is a fee to pay to the "local" registration authority. An iPhone game it is downloaded and not played on air (or physically distributed), and hence I think there is a specific legislation for this that specifies how much one should pay. I own some of the tracks composed and for this I think I won't have to pay a royalty (even if the track has an ISRC code) but for other tracks I just have a license "to use". I wonder how a game like Guitar hero can sell on iPhone for as little as 0,99$ and then have "in app purchases" for packs of 3 songs (for about 2 dollars) and make a profit (I imagine they will have to pay a ISRC royalty). Does anyone of you have any idea of this can work or if there is a section in this forum where I can ask this question? I understand is not about coding but I think is about development of a game in the broader sense.

    Read the article

  • Flood fill algorithm for Game of Go

    - by Jackson Borghi
    I'm having a hell of a time trying to figure out how to make captured stones disappear. I've read everywhere that I should use the flood fill algorithm, but I haven't had any luck with that so far. Any help would be amazing! Here is my code: package Go; import static java.lang.Math.*; import static stdlib.StdDraw.*; import java.awt.Color; public class Go2 { public static Color opposite(Color player) { if (player == WHITE) { return BLACK; } return WHITE; } public static void drawGame(Color[][] board) { Color[][][] unit = new Color[400][19][19]; for (int h = 0; h < 400; h++) { for (int x = 0; x < 19; x++) { for (int y = 0; y < 19; y++) { unit[h][x][y] = YELLOW; } } } setXscale(0, 19); setYscale(0, 19); clear(YELLOW); setPenColor(BLACK); line(0, 0, 0, 19); line(19, 19, 19, 0); line(0, 19, 19, 19); line(0, 0, 19, 0); for (double i = 0; i < 19; i++) { line(0.0, i, 19, i); line(i, 0.0, i, 19); } for (int x = 0; x < 19; x++) { for (int y = 0; y < 19; y++) { if (board[x][y] != YELLOW) { setPenColor(board[x][y]); filledCircle(x, y, 0.47); setPenColor(GRAY); circle(x, y, 0.47); } } } int h = 0; } public static void main(String[] args) { int px; int py; Color[][] temp = new Color[19][19]; Color[][] board = new Color[19][19]; Color player = WHITE; for (int i = 0; i < 19; i++) { for (int h = 0; h < 19; h++) { board[i][h] = YELLOW; temp[i][h] = YELLOW; } } while (true) { drawGame(board); while (!mousePressed()) { } px = (int) round(mouseX()); py = (int) round(mouseY()); board[px][py] = player; while (mousePressed()) { } floodFill(px, py, player, board, temp); System.out.print("XXXXX = "+ temp[px][py]); if (checkTemp(temp, board, px, py)) { for (int x = 0; x < 19; x++) { for (int y = 0; y < 19; y++) { if (temp[x][y] == GRAY) { board[x][y] = YELLOW; } } } } player = opposite(player); } } private static boolean checkTemp(Color[][] temp, Color[][] board, int x, int y) { if (x < 19 && x > -1 && y < 19 && y > -1) { if (temp[x + 1][y] == YELLOW || temp[x - 1][y] == YELLOW || temp[x][y - 1] == YELLOW || temp[x][y + 1] == YELLOW) { return false; } } if (x == 18) { if (temp[x - 1][y] == YELLOW || temp[x][y - 1] == YELLOW || temp[x][y + 1] == YELLOW) { return false; } } if (y == 18) { if (temp[x + 1][y] == YELLOW || temp[x - 1][y] == YELLOW || temp[x][y - 1] == YELLOW) { return false; } } if (y == 0) { if (temp[x + 1][y] == YELLOW || temp[x - 1][y] == YELLOW || temp[x][y + 1] == YELLOW) { return false; } } if (x == 0) { if (temp[x + 1][y] == YELLOW || temp[x][y - 1] == YELLOW || temp[x][y + 1] == YELLOW) { return false; } } else { if (x < 19) { if (temp[x + 1][y] == GRAY) { checkTemp(temp, board, x + 1, y); } } if (x >= 0) { if (temp[x - 1][y] == GRAY) { checkTemp(temp, board, x - 1, y); } } if (y < 19) { if (temp[x][y + 1] == GRAY) { checkTemp(temp, board, x, y + 1); } } if (y >= 0) { if (temp[x][y - 1] == GRAY) { checkTemp(temp, board, x, y - 1); } } } return true; } private static void floodFill(int x, int y, Color player, Color[][] board, Color[][] temp) { if (board[x][y] != player) { return; } else { temp[x][y] = GRAY; System.out.println("x = " + x + " y = " + y); if (x < 19) { floodFill(x + 1, y, player, board, temp); } if (x >= 0) { floodFill(x - 1, y, player, board, temp); } if (y < 19) { floodFill(x, y + 1, player, board, temp); } if (y >= 0) { floodFill(x, y - 1, player, board, temp); } } } }

    Read the article

  • Good resources for JavaScript 2D game programming?

    - by DJCouchyCouch
    As an exercise, I've decided to look into JavaScript for game programming. While it's far from being the best language for that, I do like the idea that it's cross-platform and it's always available as a web page. So I thought I'd see what I could do with it. Specifically, I'd like to make a 2D tile-based game of some kind. Where can I find resources to do that? I'm sure this question's come up before, but I can't find any reference to it.

    Read the article

  • How do I get a window caption?

    - by P.Brian.Mackey
    I would like to get a Window Caption as given by spy++ (highlighted in red) I have code to do this (or so I thought)...but it seems to work pretty awful....in some cases 1% of the time... public delegate bool EnumDelegate(IntPtr hWnd, int lParam); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool IsWindowVisible(IntPtr hWnd); [DllImport("user32.dll", EntryPoint = "GetWindowText", ExactSpelling = false, CharSet = CharSet.Auto, SetLastError = true)] static extern int GetWindowText(IntPtr hWnd, StringBuilder lpWindowText, int nMaxCount); [DllImport("user32.dll", EntryPoint = "EnumDesktopWindows", ExactSpelling = false, CharSet = CharSet.Auto, SetLastError = true)] static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumDelegate lpEnumCallbackFunction, IntPtr lParam); static List<NativeWindow> collection = new List<NativeWindow>(); public static NativeWindow GetAppNativeMainWindow() { GetNativeWindowHelper.EnumDelegate filter = delegate(IntPtr hWnd, int lParam) { StringBuilder strbTitle = new StringBuilder(255); int nLength = GetNativeWindowHelper.GetWindowText(hWnd, strbTitle, strbTitle.Capacity + 1); string strTitle = strbTitle.ToString(); if (!string.IsNullOrEmpty(strTitle)) { if (strTitle.ToLower().StartsWith("window title | my application")) { NativeWindow window = new NativeWindow(); window.AssignHandle(hWnd); collection.Add(window); return false;//stop enumerating } } return true;//continue enumerating }; GetNativeWindowHelper.EnumDesktopWindows(IntPtr.Zero, filter, IntPtr.Zero); if (collection.Count != 1) { //log error ReleaseWindow(); return null; } else return collection[0]; } public static void ReleaseWindow() { foreach (var item in collection) { item.ReleaseHandle(); } }

    Read the article

  • Subclassing ViewPager Breaks Animation

    - by Ryan Thomas
    In my Android application I have an activity which uses a view pager to display 4+ pages (Fragments). I implemented buttons on each screen that move between pages by calling: pager.setCurrentItem(position, true); The view pager and fragments are all working as I desired. I then began looking for a solution to disable user swiping between pages so that the transition between pages in handled by the buttons only. The solution I found was mentioned in a few stackoverflow articles as well as This Blog that suggest subclassing the view pager to intercept touch events to disable swiping. I followed those examples by subclassing the view pager class as follows: public class ViewPager extends android.support.v4.view.ViewPager { private boolean enabled; public ViewPager(Context context, AttributeSet attrs) { super(context, attrs); this.enabled = true; } @Override public boolean onTouchEvent(MotionEvent event) { if (this.enabled) { return super.onTouchEvent(event); } return false; } @Override public boolean onInterceptTouchEvent(MotionEvent event) { if (this.enabled) { return super.onInterceptTouchEvent(event); } return false; } public void setSwipingEnabled(boolean enabled) { this.enabled = enabled; } } Using the subclassed view pager and calling setSwipingEnabled(false) works as was desired. The user can no longer move between pages with swipe gestures and I can still move between pages via button clicks by calling setCurrentItem(int position, boolean smoothScroll). However using the subclass breaks the animation between pages. When I call setCurrentItem(position, true) with android.support.v4.view.ViewPager I get very clean scrolling animations between pages. When I make the same call using the subclass the screen has a very brief 'flash' and then automatically draws the new page. I would like to know how to fix the animation while retaining the ability to disable user swiping between pages. I greatly appreciate any help with this. Let me know if you need any additional information. So far I have tested using a Samsung device running 2.3.5 and an AVD emulator targeting Android 2.3.3.

    Read the article

  • Add Expansion Button to Stackpanel

    - by scientist
    I'd like to add Elements to a StackPanel (or Listbox / Listview if it would make that easier) and automatically add a Button (like "...") to indicate that there are more children than there is space for. Consider a calendar that has appointment items in each day. If there are more appointments than as much as can be displayed a button is displayed to go to a detailed view for that day. Can this be done automatically, or how do I calculate the positions of the stackpanel and its items. It's for windows store development in c#. Thanks in advance.

    Read the article

  • Composing adaptors in Boost::range

    - by bruno nery
    I started playing with Boost::Range in order to have a pipeline of lazy transforms in C++]1. My problem now is how to split a pipeline in smaller parts. Suppose I have: int main(){ auto map = boost::adaptors::transformed; // shorten the name auto sink = generate(1) | map([](int x){ return 2*x; }) | map([](int x){ return x+1; }) | map([](int x){ return 3*x; }); for(auto i : sink) std::cout << i << "\n"; } And I want to replace the first two maps with a magic_transform, i.e.: int main(){ auto map = boost::adaptors::transformed; // shorten the name auto sink = generate(1) | magic_transform() | map([](int x){ return 3*x; }); for(auto i : sink) std::cout << i << "\n"; } How would one write magic_transform? I looked up Boost::Range's documentation, but I can't get a good grasp of it.

    Read the article

  • Browser is showing PHP code instead of processing it

    - by FarrisFahad
    I have installed XAMPP on my computer which is Windows 8 pro. I use to work with Windows 7 every time I run the index.php file on Windows 8 it shows the code on the browser IE10. Here is what I have done: I have named the file correctly: index.php I have installed the server and saved the files inside c:/xampp/htdocs/PHP/ I have used to open and close all PHP tags and everything else seems working fine, like, PHPMyAdmin, and the Ini file I don't know whats wrong and it is driving me crazy ... Farris

    Read the article

  • jquery get width of previous image

    - by user1250987
    So i cant get the jquery correct for this one, whatever i try it returns the wrong width. I wish to make the image within the "img-shadow" div the same size as the image right before it. Notice this will repeat several times on the page. <p> <img src="" alt=""> <div class="img-shadow"> <img src="" alt=""> </div> </p> I hope you don't shake your heads too much on at me on this one, it seems super simple, but .prev .find .closest hasn't worked for me. Thanks!

    Read the article

  • implementing gravity to projectile - delta time issue

    - by Murat Nafiz
    I'm trying to implement a simple projectile motion in Android (with openGL). And I want to add gravity to my world to simulate a ball's dropping realistically. I simply update my renderer with a delta time which is calculated by: float deltaTime = (System.nanoTime()-startTime) / 1000000000.0f; startTime = System.nanoTime(); screen.update(deltaTime); In my screen.update(deltaTime) method: if (isballMoving) { golfBall.updateLocationAndVelocity(deltaTime); } And in golfBall.updateLocationAndVelocity(deltaTime) method: public final static double G = -9.81; double vz0 = getVZ0(); // Gets initial velocity(z) double z0 = getZ0(); // Gets initial height double time = getS(); // gets total time from act begin double vz = vz0 + G * deltaTime; // calculate new velocity(z) double z = z0 - vz0 * deltaTime- 0.5 * G * deltaTime* deltaTime; // calculate new position time = time + deltaTime; // Update time setS(time); //set new total time Now here is the problem; If I set deltaTime as 0.07 statically, then the animation runs normally. But since the update() method runs as faster as it can, the length and therefore the speed of the ball varies from device to device. If I don't touch deltaTime and run the program (deltaTime's are between 0.01 - 0.02 with my test devices) animation length and the speed of ball are same at different devices. But the animation is so SLOW! What am I doing wrong?

    Read the article

  • Predicate usually used for array/list how about here?

    - by amit kohan
    In following code (Josh Smith's article on MVVM), can somebody give me some insight about return _canExecute == null ? true : _canExecute(parameter); ? it is a normal if/else statement but I'm not getting the last part of it. public class RelayCommand : ICommand { #region Fields readonly Action<object> _execute; readonly Predicate<object> _canExecute; #endregion // Fields #region Constructors public RelayCommand(Action<object> execute) : this(execute, null) { } public RelayCommand(Action<object> execute, Predicate<object> canExecute) { if (execute == null) throw new ArgumentNullException("execute"); _execute = execute; _canExecute = canExecute; } #endregion // Constructors #region ICommand Members [DebuggerStepThrough] public bool CanExecute(object parameter) { return _canExecute == null ? true : _canExecute(parameter); } public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } public void Execute(object parameter) { _execute(parameter); } #endregion // ICommand Members } Thanks.

    Read the article

  • Return value from Object match

    - by Hito_kun
    I'm, by no means, JS fluent, so forgive me if im asking for some really basic stuff, but I've not being able to find a proper answer to my question. Im writting my first Node.js (plus Extra Framework and Socket.io) app and Im having some fun setting up the server side of a FB-like messenger (surprise!!!). So, let's say I have this data structure to store online users(This is a JSON Array, but I'm not sure it is the best way to do it or should I go with Javascript Objects): [ { "site": 45, "users": [ { "idUser": 5, "idSocket": "qwe87r7w8qwe", "name": "Carlos Ray Norris" }, { "idUser": 6, "idSocket": "v8d9d0fgfs7d", "name": "John Connor" } ] }, { "site": 48, "users": [ { "idUser": 22, "idSocket": "qwe87r7w8qwe", "name": "David Bowie" }, { "idUser": 23, "idSocket": "v8d9d0fgfs7d", "name": "Barack H. Obama" } ] } ] What I want to do is to search in the array for x value given y. In this case, retrieving the idSocket knowing the idUser WITHOUT having to run through the array values. So I have basically 2 questions: first, what would be the proper way to store users online? and secondly, how to find values matching with the values I already know (find the idSocket that has a given idUser). I would like a pure JS approach(or using some of the tools given by Node, Socket.io or Express), but if that's not possible then I can look for some JQuery.

    Read the article

  • abstract class need acces to subclass atribute

    - by user1742980
    I have a problem with my code. public abstract class SimplePolygon implements Polygon { ... public String toString(){ String str = "Polygon: vertices ="; for(int i = 0;i<varray.length;i++){ str += " "; str += varray[i]; } return str; } } public class ArrayPolygon extends SimplePolygon { private Vertex2D[] varray; public ArrayPolygon(Vertex2D[] array){ varray = new Vertex2D[array.length]; if (array == null){} for(int i = 0;i<array.length;i++){ if (array[i] == null){} varray[i] = array[i]; } ... } Problem is, that i'm not allowed to add any atribute or method to abstract class SimplePolygon, so i'cant properly initialize varray. It could simply be solved with protected atrib in that class, but for some (stupid) reason i'cant do that. Has anybody an idea how to solve it without that? Thanks for all help.

    Read the article

  • How to implement Voting for Grails Domain Classes?

    - by userWebMobile
    I have a Book class and need to implement a yes/no voting functionality. My domain classes look like this: class Book { String title static hasMany = [votes: Vote] } class User { String name static hasMany = [votes: Vote] } class Vote { boolean yesVote static belongsTo = [user: User, book: Book] } What is the best way to implement a voting for the book class. I need the following informations: What is the average yesVote for a book over all votes (either yes or no)? How to check if a specific user has done a vote? What is the best way to implement the computation of the average yesVote such that the performance does not drop?

    Read the article

  • Rewinding or resetting Parallel effect in Flex 3

    - by errata
    How can I 'rewind' or force the parallel effect to play from the very beginning once it already started to play? Code sample: <mx:Parallel id="parallelEffect" repeatCount="0"> <mx:Fade alphaTo="1" target="{someTarget}" startDelay="2000" /> <mx:Fade alphaTo="1" target="{someOtherTarget}" startDelay="4000" /> <mx:Fade alphaTo="1" target="{thirdTarget}" startDelay="6000" /> <mx:Fade alphaTo="1" target="{fourthTarget}" startDelay="8000" /> <mx:Fade alphaTo="1" target="{fifthTarget}" startDelay="10000" /> </mx:Parallel>

    Read the article

  • HABTM selection seemingly ignores joinTable

    - by TheCapn
    I'm attempting to do a HABTM relationship between a Users table and Groups table. The problem is, that I when I issue this call: $this->User->Group->find('list'); The query that is issued is: SELECT [Group].[id] AS [Group__id], [Group].[name] AS [Group__name] FROM [groups] AS [Group] WHERE 1 = 1 I can only assume at this point that I have defined my relationship wrong as I would expect behavior to use the groups_users table that is defined on the database as per convention. My relationships: class User extends AppModel { var $name = 'User'; //...snip... var $hasAndBelongsToMany = array( 'Group' => array( 'className' => 'Group', 'foreignKey' => 'user_id', 'associationForeignKey' => 'group_id', 'joinTable' => 'groups_users', 'unique' => true, ) ); //...snip... } class Group extends AppModel { var $name = 'Group'; var $hasAndBelongsToMany = array ( 'User' => array( 'className' => 'User', 'foreignKey' => 'group_id', 'associationForeignKey' => 'user_id', 'joinTable' => 'groups_users', 'unique' => true, )); } Is my understanding of HABTM wrong? How would I implement this Many to Many relationship where I can use CakePHP to query the groups_users table such that a list of groups the currently authenticated user is associated with is returned?

    Read the article

  • How to read back and print text with newlines from a Python (Django) string with HTML?

    - by user1801486
    If someone types in a phrase, such as: I see you driving round town with the girl I love, and I’m like: haiku. (no blank lines between each line, but the text is written on three separate lines) into a text box on a web page, and then presses a button which is then stored in a database via Django, and that string is read back and printed on a page, how can I get it to print on an HTML page with the newlines still in the text? So instead of it being printed back as: I see you driving round town with the girl I love, and I’m like: haiku. It would print as: I see you driving round town with the girl I love, and I’m like: haiku. I know that if I use: (textarea)soAndSo.body(/textarea), this preserves the newlines that were in the file when the user typed it up originally. How can I get this same effect, but without having to use textarea boxes?

    Read the article

  • Qt QTextEdit Qt4.2 Valid HTML String

    - by Matthew Hoggan
    I am trying to generate the correct HTML to render to a QTextEdit Using Qt 4.2 on RHEL 5.3. So far my algorithm generates the following html. I am not an expert web developer, but to me this string seems valid. 319:14:27:22: <font color="rgb(255,0,0)" bgcolor="rgb(255,0,0)">Message</font><br> What needs to change to get the colours to render. Currently it just renders as black text on a white background.

    Read the article

  • Add/delete row from a table

    - by yogsma
    I have this table with some dependents information and there is a add and delete button for each row to add/delete additional dependents. When I click "add" button, a new row gets added to the table, but when I click the "delete" button, it deletes the header row first and then on subsequent clicking, it deletes the corresponding row. Here is what I have: Javascript code function deleteRow(row){ var d = row.parentNode.parentNode.rowIndex; document.getElementById('dsTable').deleteRow(d); } HTML code <table id = 'dsTable' > <tr> <td> Relationship Type </td> <td> Date of Birth </td> <td> Gender </td> </tr> <tr> <td> Spouse </td> <td> 1980-22-03 </td> <td> female </td> <td> <input type="button" id ="addDep" value="Add" onclick = "add()" </td> <td> <input type="button" id ="deleteDep" value="Delete" onclick = "deleteRow(this)" </td> </tr> <tr> <td> Child </td> <td> 2008-23-06 </td> <td> female </td> <td> <input type="button" id ="addDep" value="Add" onclick = "add()"</td> <td> <input type="button" id ="deleteDep" value="Delete" onclick = "deleteRow(this)" </td> </tr> </table>

    Read the article

  • How will Facebook Authenticate let me ID a user?

    - by Donny P
    I have a website where I need to have data that is ID'd by user. For example, they enter their favorite food: userid favorite food ------ ------------- 1 french fries 2 tacos 3 fish sticks 4 chipotle When I use Facebook Authentication, what identifier will I use for the userid? I'm assuming it's not name, since this would create duplicates. Is it just the person's Facebook ID? Also is the correct API to use for 3rd party websites 'Facebook Connect' or 'Facebook Authorization' or something else?

    Read the article

  • Can I take the voice data (f.e. in mp3 format) from speech recognition? [closed]

    - by Ersin Gulbahar
    Possible Duplicate: Android: Voice Recording and saving audio I mean ; I use voice recognition classes on android and I succeed voice recognition. But I want to real voice data not words instead of it. For example I said 'teacher' and android get you said teacher.Oh ok its good but I want to my voice which include 'teacher'.Where is it ? Can I take it and save another location? I use this class to speech to text : package net.viralpatel.android.speechtotextdemo; import java.util.ArrayList; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; import android.os.Bundle; import android.speech.RecognizerIntent; import android.view.Menu; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { protected static final int RESULT_SPEECH = 1; private ImageButton btnSpeak; private TextView txtText; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txtText = (TextView) findViewById(R.id.txtText); btnSpeak = (ImageButton) findViewById(R.id.btnSpeak); btnSpeak.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent( RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US"); try { startActivityForResult(intent, RESULT_SPEECH); txtText.setText(""); } catch (ActivityNotFoundException a) { Toast t = Toast.makeText(getApplicationContext(), "Ops! Your device doesn't support Speech to Text", Toast.LENGTH_SHORT); t.show(); } } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case RESULT_SPEECH: { if (resultCode == RESULT_OK && null != data) { ArrayList<String> text = data .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); txtText.setText(text.get(0)); } break; } } } } Thanks.

    Read the article

  • Handling multiple media queries in Sass with Twitter Bootstrap

    - by Keith
    I have a Sass mixin for my media queries based on Twitter Bootstrap's responsive media queries: @mixin respond-to($media) { @if $media == handhelds { /* Landscape phones and down */ @media (max-width: 480px) { @content; } } @else if $media == small { /* Landscape phone to portrait tablet */ @media (max-width: 767px) {@content; } } @else if $media == medium { /* Portrait tablet to landscape and desktop */ @media (min-width: 768px) and (max-width: 979px) { @content; } } @else if $media == large { /* Large desktop */ @media (min-width: 1200px) { @content; } } @else { @media only screen and (max-width: #{$media}px) { @content; } } } And I call them throughout my SCSS file like so: .link { color:blue; @include respond-to(medium) { color: red; } } However, sometimes I want to style multiple queries with the same styles. Right now I'm doing them like this: .link { color:blue; /* this is fine for handheld and small sizes*/ /*now I want to change the styles that are cascading to medium and large*/ @include respond-to(medium) { color: red; } @include respond-to(large) { color: red; } } but I'm repeating code so I'm wondering if there is a more concise way to write it so I can target multiple queries. Something like this so I don't need to repeat my code (I know this doesn't work): @include respond-to(medium, large) { color: red; } Any suggestions on the best way to handle this?

    Read the article

  • Retrieve only the superclass from a class hierarchy

    - by user1792724
    I have an scenario as the following: @Entity @Table(name = "ANIMAL") @Inheritance(strategy = InheritanceType.JOINED) public class Animal implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "S_ANIMAL") @SequenceGenerator(name = "S_ANIMAL", sequenceName = "S_ANIMAL", allocationSize = 1) public int getNumero() { return numero; } public void setNumero(int numero) { this.numero = numero; } . . . } and as the subclass: @Entity @Table(name = "DOG") public class Dog extends Animal { private static final long serialVersionUID = -7341592543130659641L; . . . } I have a JPA Select statement like this: SELECT a FROM Animal a; I'm using Hibernate 3.3.1 As I can see the framework retrieves instances of Animal and also of Dog using a left outer join. Is there a way to Select only the "part" Animal? I mean, the previous Select will get all the Animals, those that are only Animals but not Dogs and those that are Dogs. I want them all, but in the case of Dogs I want to only retrieve the "Animal part" of them. I found the @org.hibernate.annotations.Entity(polymorphism = PolymorphismType.EXPLICIT) but as I could see this only works if Animal isn't an @Entity. Thanks a lot.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17  | Next Page >